forked from square/dagger
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove caching of
@AssistedInject
bindings to work around b/305748522.
This is a short-term fix for b/305748522 so that we can push through our other fix for b/302199325. The long-term fix is outlined in the b/305748522 but probably requires more design discussion. RELNOTES=N/A PiperOrigin-RevId: 573855920
- Loading branch information
Showing
4 changed files
with
361 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
...Test_testMultipleAssistedFactoryInDifferentComponents_DEFAULT_MODE_test.DaggerMyComponent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package test; | ||
|
||
import dagger.internal.DaggerGenerated; | ||
import javax.annotation.processing.Generated; | ||
import javax.inject.Provider; | ||
|
||
@DaggerGenerated | ||
@Generated( | ||
value = "dagger.internal.codegen.ComponentProcessor", | ||
comments = "https://dagger.dev" | ||
) | ||
@SuppressWarnings({ | ||
"unchecked", | ||
"rawtypes", | ||
"KotlinInternal", | ||
"KotlinInternalInJava" | ||
}) | ||
final class DaggerMyComponent { | ||
private DaggerMyComponent() { | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
public static MyComponent create() { | ||
return new Builder().build(); | ||
} | ||
|
||
static final class Builder { | ||
private Builder() { | ||
} | ||
|
||
public MyComponent build() { | ||
return new MyComponentImpl(); | ||
} | ||
} | ||
|
||
private static final class MySubcomponentImpl implements MySubcomponent { | ||
private final MyComponentImpl myComponentImpl; | ||
|
||
private final MySubcomponentImpl mySubcomponentImpl = this; | ||
|
||
private MyAssistedClass_Factory myAssistedClassProvider; | ||
|
||
private Provider<MySubcomponentAssistedFactory> mySubcomponentAssistedFactoryProvider; | ||
|
||
private MySubcomponentImpl(MyComponentImpl myComponentImpl) { | ||
this.myComponentImpl = myComponentImpl; | ||
|
||
initialize(); | ||
|
||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
private void initialize() { | ||
this.myAssistedClassProvider = MyAssistedClass_Factory.create(Baz_Factory.create()); | ||
this.mySubcomponentAssistedFactoryProvider = MySubcomponentAssistedFactory_Impl.create(myAssistedClassProvider); | ||
} | ||
|
||
@Override | ||
public MySubcomponentAssistedFactory mySubcomponentAssistedFactory() { | ||
return mySubcomponentAssistedFactoryProvider.get(); | ||
} | ||
} | ||
|
||
private static final class MyComponentImpl implements MyComponent { | ||
private final MyComponentImpl myComponentImpl = this; | ||
|
||
private MyAssistedClass_Factory myAssistedClassProvider; | ||
|
||
private Provider<MyComponentAssistedFactory> myComponentAssistedFactoryProvider; | ||
|
||
private MyComponentImpl() { | ||
|
||
initialize(); | ||
|
||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
private void initialize() { | ||
this.myAssistedClassProvider = MyAssistedClass_Factory.create(Baz_Factory.create()); | ||
this.myComponentAssistedFactoryProvider = MyComponentAssistedFactory_Impl.create(myAssistedClassProvider); | ||
} | ||
|
||
@Override | ||
public MyComponentAssistedFactory myComponentAssistedFactory() { | ||
return myComponentAssistedFactoryProvider.get(); | ||
} | ||
|
||
@Override | ||
public MySubcomponent mySubcomponent() { | ||
return new MySubcomponentImpl(myComponentImpl); | ||
} | ||
} | ||
} |
149 changes: 149 additions & 0 deletions
149
...st_testMultipleAssistedFactoryInDifferentComponents_FAST_INIT_MODE_test.DaggerMyComponent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
package test; | ||
|
||
import dagger.internal.DaggerGenerated; | ||
import dagger.internal.SingleCheck; | ||
import javax.annotation.processing.Generated; | ||
import javax.inject.Provider; | ||
|
||
@DaggerGenerated | ||
@Generated( | ||
value = "dagger.internal.codegen.ComponentProcessor", | ||
comments = "https://dagger.dev" | ||
) | ||
@SuppressWarnings({ | ||
"unchecked", | ||
"rawtypes", | ||
"KotlinInternal", | ||
"KotlinInternalInJava" | ||
}) | ||
final class DaggerMyComponent { | ||
private DaggerMyComponent() { | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
public static MyComponent create() { | ||
return new Builder().build(); | ||
} | ||
|
||
static final class Builder { | ||
private Builder() { | ||
} | ||
|
||
public MyComponent build() { | ||
return new MyComponentImpl(); | ||
} | ||
} | ||
|
||
private static final class MySubcomponentImpl implements MySubcomponent { | ||
private final MyComponentImpl myComponentImpl; | ||
|
||
private final MySubcomponentImpl mySubcomponentImpl = this; | ||
|
||
private Provider<MySubcomponentAssistedFactory> mySubcomponentAssistedFactoryProvider; | ||
|
||
private MySubcomponentImpl(MyComponentImpl myComponentImpl) { | ||
this.myComponentImpl = myComponentImpl; | ||
|
||
initialize(); | ||
|
||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
private void initialize() { | ||
this.mySubcomponentAssistedFactoryProvider = SingleCheck.provider(new SwitchingProvider<MySubcomponentAssistedFactory>(myComponentImpl, mySubcomponentImpl, 0)); | ||
} | ||
|
||
@Override | ||
public MySubcomponentAssistedFactory mySubcomponentAssistedFactory() { | ||
return mySubcomponentAssistedFactoryProvider.get(); | ||
} | ||
|
||
private static final class SwitchingProvider<T> implements Provider<T> { | ||
private final MyComponentImpl myComponentImpl; | ||
|
||
private final MySubcomponentImpl mySubcomponentImpl; | ||
|
||
private final int id; | ||
|
||
SwitchingProvider(MyComponentImpl myComponentImpl, MySubcomponentImpl mySubcomponentImpl, | ||
int id) { | ||
this.myComponentImpl = myComponentImpl; | ||
this.mySubcomponentImpl = mySubcomponentImpl; | ||
this.id = id; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public T get() { | ||
switch (id) { | ||
case 0: // test.MySubcomponentAssistedFactory | ||
return (T) new MySubcomponentAssistedFactory() { | ||
@Override | ||
public MyAssistedClass create(Bar bar, Foo foo) { | ||
return new MyAssistedClass(foo, new Baz(), bar); | ||
} | ||
}; | ||
|
||
default: throw new AssertionError(id); | ||
} | ||
} | ||
} | ||
} | ||
|
||
private static final class MyComponentImpl implements MyComponent { | ||
private final MyComponentImpl myComponentImpl = this; | ||
|
||
private Provider<MyComponentAssistedFactory> myComponentAssistedFactoryProvider; | ||
|
||
private MyComponentImpl() { | ||
|
||
initialize(); | ||
|
||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
private void initialize() { | ||
this.myComponentAssistedFactoryProvider = SingleCheck.provider(new SwitchingProvider<MyComponentAssistedFactory>(myComponentImpl, 0)); | ||
} | ||
|
||
@Override | ||
public MyComponentAssistedFactory myComponentAssistedFactory() { | ||
return myComponentAssistedFactoryProvider.get(); | ||
} | ||
|
||
@Override | ||
public MySubcomponent mySubcomponent() { | ||
return new MySubcomponentImpl(myComponentImpl); | ||
} | ||
|
||
private static final class SwitchingProvider<T> implements Provider<T> { | ||
private final MyComponentImpl myComponentImpl; | ||
|
||
private final int id; | ||
|
||
SwitchingProvider(MyComponentImpl myComponentImpl, int id) { | ||
this.myComponentImpl = myComponentImpl; | ||
this.id = id; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public T get() { | ||
switch (id) { | ||
case 0: // test.MyComponentAssistedFactory | ||
return (T) new MyComponentAssistedFactory() { | ||
@Override | ||
public MyAssistedClass create(Bar bar, Foo foo) { | ||
return new MyAssistedClass(foo, new Baz(), bar); | ||
} | ||
}; | ||
|
||
default: throw new AssertionError(id); | ||
} | ||
} | ||
} | ||
} | ||
} |