Skip to content

Commit e62fb19

Browse files
bcorsoDagger Team
authored andcommitted
Remove the usesProducers compiler option.
This CL removes `CompilerOptions#usesProducers()` because it wasn't even a compiler option to begin with. In particular, users can't change this value with a particular flag, rather it just depends on whether producers is in your classpath or not. RELNOTES=N/A PiperOrigin-RevId: 682464323
1 parent 8ba8242 commit e62fb19

File tree

4 files changed

+10
-18
lines changed

4 files changed

+10
-18
lines changed

java/dagger/internal/codegen/bindinggraphvalidation/DependsOnProductionExecutorValidator.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
import static dagger.internal.codegen.extension.DaggerStreams.instancesOf;
2020
import static javax.tools.Diagnostic.Kind.ERROR;
2121

22+
import androidx.room.compiler.processing.XProcessingEnv;
2223
import dagger.internal.codegen.binding.KeyFactory;
23-
import dagger.internal.codegen.compileroption.CompilerOptions;
24+
import dagger.internal.codegen.javapoet.TypeNames;
2425
import dagger.internal.codegen.model.Binding;
2526
import dagger.internal.codegen.model.BindingGraph;
2627
import dagger.internal.codegen.model.BindingGraph.MaybeBinding;
@@ -34,12 +35,12 @@
3435
*/
3536
// TODO(dpb,beder): Validate this during @Inject/@Provides/@Produces validation.
3637
final class DependsOnProductionExecutorValidator extends ValidationBindingGraphPlugin {
37-
private final CompilerOptions compilerOptions;
38+
private final XProcessingEnv processingEnv;
3839
private final KeyFactory keyFactory;
3940

4041
@Inject
41-
DependsOnProductionExecutorValidator(CompilerOptions compilerOptions, KeyFactory keyFactory) {
42-
this.compilerOptions = compilerOptions;
42+
DependsOnProductionExecutorValidator(XProcessingEnv processingEnv, KeyFactory keyFactory) {
43+
this.processingEnv = processingEnv;
4344
this.keyFactory = keyFactory;
4445
}
4546

@@ -50,7 +51,7 @@ public String pluginName() {
5051

5152
@Override
5253
public void visitGraph(BindingGraph bindingGraph, DiagnosticReporter diagnosticReporter) {
53-
if (!compilerOptions.usesProducers()) {
54+
if (!usesProducers()) {
5455
return;
5556
}
5657

@@ -69,4 +70,8 @@ private void reportError(DiagnosticReporter diagnosticReporter, Binding binding)
6970
diagnosticReporter.reportBinding(
7071
ERROR, binding, "%s may not depend on the production executor", binding.key());
7172
}
73+
74+
private boolean usesProducers() {
75+
return processingEnv.findTypeElement(TypeNames.PRODUCES) != null;
76+
}
7277
}

java/dagger/internal/codegen/compileroption/CompilerOptions.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
/** A collection of options that dictate how the compiler will run. */
2323
public abstract class CompilerOptions {
24-
public abstract boolean usesProducers();
25-
2624
/**
2725
* Returns true if the fast initialization flag, {@code fastInit}, is enabled.
2826
*

java/dagger/internal/codegen/compileroption/ProcessingEnvironmentCompilerOptions.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
import com.google.common.collect.ImmutableList;
6363
import com.google.common.collect.ImmutableMap;
6464
import com.google.common.collect.ImmutableSet;
65-
import dagger.internal.codegen.javapoet.TypeNames;
6665
import java.util.Arrays;
6766
import java.util.EnumSet;
6867
import java.util.HashMap;
@@ -96,11 +95,6 @@ public final class ProcessingEnvironmentCompilerOptions extends CompilerOptions
9695
checkValid();
9796
}
9897

99-
@Override
100-
public boolean usesProducers() {
101-
return processingEnv.findTypeElement(TypeNames.PRODUCES) != null;
102-
}
103-
10498
@Override
10599
public boolean headerCompilation() {
106100
return isEnabled(HEADER_COMPILATION);

java/dagger/internal/codegen/javac/JavacPluginCompilerOptions.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ final class JavacPluginCompilerOptions extends CompilerOptions {
3131
@Inject
3232
JavacPluginCompilerOptions() {}
3333

34-
@Override
35-
public boolean usesProducers() {
36-
return true;
37-
}
38-
3934
@Override
4035
public boolean fastInit(XTypeElement element) {
4136
return false;

0 commit comments

Comments
 (0)