diff --git a/java/dagger/internal/codegen/binding/BindingGraphFactory.java b/java/dagger/internal/codegen/binding/BindingGraphFactory.java index 7dcabe4bbcf..503435901ed 100644 --- a/java/dagger/internal/codegen/binding/BindingGraphFactory.java +++ b/java/dagger/internal/codegen/binding/BindingGraphFactory.java @@ -44,6 +44,7 @@ import dagger.Reusable; import dagger.internal.codegen.base.ClearableCache; import dagger.internal.codegen.base.ContributionType; +import dagger.internal.codegen.base.DaggerSuperficialValidation; import dagger.internal.codegen.base.Keys; import dagger.internal.codegen.base.MapType; import dagger.internal.codegen.base.OptionalType; @@ -261,7 +262,8 @@ private ImmutableSet modules( .addAll(componentDescriptor.modules()) .add( moduleDescriptorFactory.create( - processingEnv.requireTypeElement( + DaggerSuperficialValidation.requireTypeElement( + processingEnv, generatedMonitoringModuleName(componentDescriptor.typeElement())))) .add( moduleDescriptorFactory.create( diff --git a/javatests/dagger/internal/codegen/ProductionComponentProcessorTest.java b/javatests/dagger/internal/codegen/ProductionComponentProcessorTest.java index b9758c121fa..39e63c99eac 100644 --- a/javatests/dagger/internal/codegen/ProductionComponentProcessorTest.java +++ b/javatests/dagger/internal/codegen/ProductionComponentProcessorTest.java @@ -201,6 +201,51 @@ public void dependsOnProductionExecutor() throws Exception { // TODO(dpb): Report at the binding if enclosed in the module. } + @Test + public void dependsOnProductionSubcomponentWithPluginsVisitFullBindingGraphs() throws Exception { + Source myComponent = + CompilerTests.javaSource( + "test.MyComponent", + "package test;", + "", + "import dagger.Component;", + "", + "@Component(modules = MyModule.class)", + "interface MyComponent {}"); + Source myModule = + CompilerTests.javaSource( + "test.MyModule", + "package test;", + "", + "import dagger.Component;", + "import dagger.Module;", + "", + "@Module(subcomponents = MyProductionSubcomponent.class)", + "interface MyModule {}"); + Source myProductionSubcomponent = + CompilerTests.javaSource( + "test.MyProductionSubcomponent", + "package test;", + "", + "import dagger.producers.ProductionSubcomponent;", + "", + "@ProductionSubcomponent", + "interface MyProductionSubcomponent {", + " @ProductionSubcomponent.Builder", + " interface Builder {", + " MyProductionSubcomponent build();", + " }", + "}"); + + CompilerTests.daggerCompiler(myComponent, myModule, myProductionSubcomponent) + .withProcessingOptions( + ImmutableMap.builder() + .putAll(compilerMode.processorOptions()) + .put("dagger.pluginsVisitFullBindingGraphs", "ENABLED") + .buildOrThrow()) + .compile(subject -> subject.hasErrorCount(0)); + } + @Test public void simpleComponent() throws Exception { Source component =