Skip to content

Commit

Permalink
Rename createProviderBinding -> createSyntheticProviderBinding and Pr…
Browse files Browse the repository at this point in the history
…oviderBindingImpl -> SyntheticProviderBindingImpl, so that it's clear these are only used for synthetic provider bindings.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=300886086
  • Loading branch information
ad-fu authored and cpovirk committed Mar 16, 2020
1 parent febf8a0 commit 6f717b8
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions core/src/com/google/inject/internal/InjectorImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -358,21 +358,23 @@ private <T> BindingImpl<MembersInjector<T>> createMembersInjectorBinding(
}

/**
* Creates a synthetic binding to {@code Provider<T>}, i.e. a binding to the provider from {@code
* Binding<T>}.
* Creates a synthetic binding to {@code Provider<T>}, i.e. a framework-created JIT binding to the
* provider from {@code Binding<T>}.
*/
private <T> BindingImpl<Provider<T>> createProviderBinding(Key<Provider<T>> key, Errors errors)
throws ErrorsException {
private <T> BindingImpl<Provider<T>> createSyntheticProviderBinding(
Key<Provider<T>> key, Errors errors) throws ErrorsException {
Key<T> providedKey = getProvidedKey(key, errors);
BindingImpl<T> delegate = getBindingOrThrow(providedKey, errors, JitLimitation.NO_JIT);
return new ProviderBindingImpl<T>(this, key, delegate);
return new SyntheticProviderBindingImpl<T>(this, key, delegate);
}

private static class ProviderBindingImpl<T> extends BindingImpl<Provider<T>>
/** A framework-created JIT Provider<T> binding. */
private static class SyntheticProviderBindingImpl<T> extends BindingImpl<Provider<T>>
implements ProviderBinding<Provider<T>>, HasDependencies {
final BindingImpl<T> providedBinding;

ProviderBindingImpl(InjectorImpl injector, Key<Provider<T>> key, Binding<T> providedBinding) {
SyntheticProviderBindingImpl(
InjectorImpl injector, Key<Provider<T>> key, Binding<T> providedBinding) {
super(
injector,
key,
Expand Down Expand Up @@ -422,8 +424,8 @@ public Set<Dependency<?>> getDependencies() {

@Override
public boolean equals(Object obj) {
if (obj instanceof ProviderBindingImpl) {
ProviderBindingImpl<?> o = (ProviderBindingImpl<?>) obj;
if (obj instanceof SyntheticProviderBindingImpl) {
SyntheticProviderBindingImpl<?> o = (SyntheticProviderBindingImpl<?>) obj;
return getKey().equals(o.getKey())
&& getScoping().equals(o.getScoping())
&& Objects.equal(providedBinding, o.providedBinding);
Expand Down Expand Up @@ -895,9 +897,9 @@ private <T> BindingImpl<T> createJustInTimeBinding(
// Handle cases where T is a Provider<?>.
if (isProvider(key)) {
// These casts are safe. We know T extends Provider<X> and that given Key<Provider<X>>,
// createProviderBinding() will return BindingImpl<Provider<X>>.
// createSyntheticProviderBinding() will return BindingImpl<Provider<X>>.
@SuppressWarnings({"unchecked", "cast"})
BindingImpl<T> binding = (BindingImpl<T>) createProviderBinding((Key) key, errors);
BindingImpl<T> binding = (BindingImpl<T>) createSyntheticProviderBinding((Key) key, errors);
return binding;
}

Expand Down

0 comments on commit 6f717b8

Please sign in to comment.