Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions javatests/dagger/internal/codegen/AssistedFactoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -543,4 +543,67 @@ public void testAssistedFactoryFromLibraryWithoutProcessor() {
});
}
}

@Test
public void testPublicGenericAssistedFactoryWithPackagePrivateTypeArguments() {
Source foo =
CompilerTests.javaSource(
"pkg.a.Foo",
"package pkg.a;",
"",
"import dagger.assisted.Assisted;",
"import dagger.assisted.AssistedFactory;",
"import dagger.assisted.AssistedInject;",
"",
"public class Foo<T> {",
" @AssistedInject",
" Foo(@Assisted T arg) {}",
"",
" @AssistedFactory",
" public interface Factory<T> {",
" Foo<T> create(T arg);",
" }",
"}");

Source bar =
CompilerTests.javaSource(
"pkg.b.PackagePrivateBar", "package pkg.b;", "", "class PackagePrivateBar {}");

Source client =
CompilerTests.javaSource(
"pkg.b.Client",
"package pkg.b;",
"",
"import javax.inject.Inject;",
"import pkg.a.Foo;",
"",
"public class Client {",
" @Inject",
" Client(Foo.Factory<PackagePrivateBar> factory) {}",
"}");

Source component =
CompilerTests.javaSource(
"test.TestComponent",
"package test;",
"",
"import dagger.Component;",
"import pkg.b.Client;",
"",
"@Component",
"interface TestComponent {",
" Client getClient();",
"}");

CompilerTests.DaggerCompiler daggerCompiler =
CompilerTests.daggerCompiler(foo, bar, client, component)
.withProcessingOptions(compilerMode.processorOptions());

// TODO(b/532992111): Fix javac visibility errors when using generic @AssistedFactory interfaces
// across packages with package-private type arguments.
daggerCompiler.compile(
subject -> {
subject.hasErrorContaining("PackagePrivateBar");
});
}
}
Loading