diff --git a/java/dagger/internal/codegen/bindinggraphvalidation/DependsOnProductionExecutorValidator.java b/java/dagger/internal/codegen/bindinggraphvalidation/DependsOnProductionExecutorValidator.java index ea4d73888c7..a15c67c04f8 100644 --- a/java/dagger/internal/codegen/bindinggraphvalidation/DependsOnProductionExecutorValidator.java +++ b/java/dagger/internal/codegen/bindinggraphvalidation/DependsOnProductionExecutorValidator.java @@ -19,8 +19,9 @@ import static dagger.internal.codegen.extension.DaggerStreams.instancesOf; import static javax.tools.Diagnostic.Kind.ERROR; +import androidx.room.compiler.processing.XProcessingEnv; import dagger.internal.codegen.binding.KeyFactory; -import dagger.internal.codegen.compileroption.CompilerOptions; +import dagger.internal.codegen.javapoet.TypeNames; import dagger.internal.codegen.model.Binding; import dagger.internal.codegen.model.BindingGraph; import dagger.internal.codegen.model.BindingGraph.MaybeBinding; @@ -34,12 +35,12 @@ */ // TODO(dpb,beder): Validate this during @Inject/@Provides/@Produces validation. final class DependsOnProductionExecutorValidator extends ValidationBindingGraphPlugin { - private final CompilerOptions compilerOptions; + private final XProcessingEnv processingEnv; private final KeyFactory keyFactory; @Inject - DependsOnProductionExecutorValidator(CompilerOptions compilerOptions, KeyFactory keyFactory) { - this.compilerOptions = compilerOptions; + DependsOnProductionExecutorValidator(XProcessingEnv processingEnv, KeyFactory keyFactory) { + this.processingEnv = processingEnv; this.keyFactory = keyFactory; } @@ -50,7 +51,7 @@ public String pluginName() { @Override public void visitGraph(BindingGraph bindingGraph, DiagnosticReporter diagnosticReporter) { - if (!compilerOptions.usesProducers()) { + if (!usesProducers()) { return; } @@ -69,4 +70,8 @@ private void reportError(DiagnosticReporter diagnosticReporter, Binding binding) diagnosticReporter.reportBinding( ERROR, binding, "%s may not depend on the production executor", binding.key()); } + + private boolean usesProducers() { + return processingEnv.findTypeElement(TypeNames.PRODUCES) != null; + } } diff --git a/java/dagger/internal/codegen/compileroption/CompilerOptions.java b/java/dagger/internal/codegen/compileroption/CompilerOptions.java index 1f86ba1a915..b34e8e1d6b0 100644 --- a/java/dagger/internal/codegen/compileroption/CompilerOptions.java +++ b/java/dagger/internal/codegen/compileroption/CompilerOptions.java @@ -21,8 +21,6 @@ /** A collection of options that dictate how the compiler will run. */ public abstract class CompilerOptions { - public abstract boolean usesProducers(); - /** * Returns true if the fast initialization flag, {@code fastInit}, is enabled. * diff --git a/java/dagger/internal/codegen/compileroption/ProcessingEnvironmentCompilerOptions.java b/java/dagger/internal/codegen/compileroption/ProcessingEnvironmentCompilerOptions.java index 2920525ca53..bd112126a9c 100644 --- a/java/dagger/internal/codegen/compileroption/ProcessingEnvironmentCompilerOptions.java +++ b/java/dagger/internal/codegen/compileroption/ProcessingEnvironmentCompilerOptions.java @@ -62,7 +62,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import dagger.internal.codegen.javapoet.TypeNames; import java.util.Arrays; import java.util.EnumSet; import java.util.HashMap; @@ -96,11 +95,6 @@ public final class ProcessingEnvironmentCompilerOptions extends CompilerOptions checkValid(); } - @Override - public boolean usesProducers() { - return processingEnv.findTypeElement(TypeNames.PRODUCES) != null; - } - @Override public boolean headerCompilation() { return isEnabled(HEADER_COMPILATION); diff --git a/java/dagger/internal/codegen/javac/JavacPluginCompilerOptions.java b/java/dagger/internal/codegen/javac/JavacPluginCompilerOptions.java index 6c11fff51e7..c2f42506680 100644 --- a/java/dagger/internal/codegen/javac/JavacPluginCompilerOptions.java +++ b/java/dagger/internal/codegen/javac/JavacPluginCompilerOptions.java @@ -31,11 +31,6 @@ final class JavacPluginCompilerOptions extends CompilerOptions { @Inject JavacPluginCompilerOptions() {} - @Override - public boolean usesProducers() { - return true; - } - @Override public boolean fastInit(XTypeElement element) { return false;