core/src/com/google/inject/internal/InjectorImpl.java
<T> BindingImpl<T> createProvidedByBinding(
      Key<T> key, Scoping scoping, ProvidedBy providedBy, Errors errors) throws ErrorsException {
    Class<?> rawType = key.getTypeLiteral().getRawType();
    Class<? extends javax.inject.Provider<?>> providerType = providedBy.value();

    // Make sure it's not the same type. TODO: Can we check for deeper loops?
    if (providerType == rawType) {
      throw errors.recursiveProviderType().toException();
    }

    // Assume the provider provides an appropriate type. We double check at runtime.
    @SuppressWarnings("unchecked")
    Key<? extends Provider<T>> providerKey = (Key<? extends Provider<T>>) Key.get(providerType);
    ProvidedByInternalFactory<T> internalFactory =
        new ProvidedByInternalFactory<T>(rawType, providerType, providerKey);
    Object source = rawType;
    BindingImpl<T> binding =
        LinkedProviderBindingImpl.createWithInitializer(
            this,
            key,
            source,
            Scoping.<T>scope(key, this, internalFactory, source, scoping),
            scoping,
            providerKey,
            internalFactory);
    internalFactory.setProvisionListenerCallback(provisionListenerStore.get(binding));
    return binding;
  }
<T> BindingImpl<T> createProvidedByBinding(
      Key<T> key, Scoping scoping, ProvidedBy providedBy, Errors errors) throws ErrorsException {
    Class<?> rawType = key.getTypeLiteral().getRawType();
    Class<? extends javax.inject.Provider<?>> providerType = providedBy.value();

    // Make sure it's not the same type. TODO: Can we check for deeper loops?
    if (providerType == rawType) {
      throw errors.recursiveProviderType().toException();
    }

    // Assume the provider provides an appropriate type. We double check at runtime.
    @SuppressWarnings("unchecked")
    Key<? extends Provider<T>> providerKey = (Key<? extends Provider<T>>) Key.get(providerType);
    ProvidedByInternalFactory<T> internalFactory =
        new ProvidedByInternalFactory<T>(rawType, providerType, providerKey);
    Object source = rawType;
    BindingImpl<T> binding =
        LinkedProviderBindingImpl.createWithInitializer(
            this,
            key,
            source,
            Scoping.<T>scope(key, this, internalFactory, source, scoping),
            scoping,
            providerKey,
            internalFactory);
    internalFactory.setProvisionListenerCallback(provisionListenerStore.get(binding));
    return binding;
  }
< T > BindingImpl < T > createProvidedByBinding ( Key < T > key , Scoping scoping , ProvidedBy providedBy , Errors errors ) throws ErrorsException { Class < ? > rawType = key . getTypeLiteral ( ) . getRawType ( ) ; Class < ? extends javax . inject . Provider < ? > > providerType = providedBy . value ( ) ; // Make sure it's not the same type. TODO: Can we check for deeper loops? if ( providerType == rawType ) { throw errors . recursiveProviderType ( ) . toException ( ) ; } // Assume the provider provides an appropriate type. We double check at runtime. @ SuppressWarnings ( "unchecked" ) Key < ? extends Provider < T > > providerKey = ( Key < ? extends Provider < T > > ) Key . get ( providerType ) ; ProvidedByInternalFactory < T > internalFactory = new ProvidedByInternalFactory < T > ( rawType , providerType , providerKey ) ; Object source = rawType ; BindingImpl < T > binding = LinkedProviderBindingImpl . createWithInitializer ( this , key , source , Scoping . < T > scope ( key , this , internalFactory , source , scoping ) , scoping , providerKey , internalFactory ) ; internalFactory . setProvisionListenerCallback ( provisionListenerStore . get ( binding ) ) ; return binding ; }
Creates a binding for a type annotated with @ProvidedBy.
Creates a binding for a type annotated with