Skip to content

Commit 4cd83cb

Browse files
bcorsoDagger Team
authored and
Dagger Team
committed
Add documentation for dagger.useBindingGraphFix compiler option.
In addition to adding documentation, this CL changes the compiler option name from `useLegacyBindingGraphFactory` to `useBindingGraphFix` to flip the default (it's more intuitive when disabled means "old behavior" and enabled means "new behavior") and to give the name more meaning from a user's perspective (useLegacyBindingGraphFactory likely doesn't mean much for users). RELNOTES=N/A PiperOrigin-RevId: 713455646
1 parent 8b4f9b6 commit 4cd83cb

File tree

4 files changed

+12
-22
lines changed

4 files changed

+12
-22
lines changed

java/dagger/internal/codegen/binding/LegacyBindingGraphFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public final class LegacyBindingGraphFactory {
7070

7171
static boolean useLegacyBindingGraphFactory(
7272
CompilerOptions compilerOptions, ComponentDescriptor componentDescriptor) {
73-
return compilerOptions.useLegacyBindingGraphFactory();
73+
return !compilerOptions.useBindingGraphFix();
7474
}
7575

7676
static boolean hasStrictMultibindingsExemption(

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

+5-15
Original file line numberDiff line numberDiff line change
@@ -119,24 +119,14 @@ public final boolean doCheckForNulls() {
119119
public abstract boolean generatedClassExtendsComponent();
120120

121121
/**
122-
* Returns {@code true} if Dagger should use the legacy binding graph factory.
122+
* Returns {@code true} if Dagger should turn on the binding graph fix.
123123
*
124-
* <p>Note: This flag is only intended to give users time to migrate to the new binding graph
125-
* factory. New users should not enable this flag. This flag will be removed in a future release.
124+
* <p>Note: This flag is only intended to give users time to migrate. This flag will be removed in
125+
* a future release.
126126
*
127-
* <p>The legacy binding graph factory contains a number of bugs which can lead to an incorrect
128-
* binding graph (e.g. missing multibindings), can be difficult to debug, and are often dependent
129-
* on the ordering of bindings/dependency requests in the user's code.
130-
*
131-
* <p>The new binding graph factory fixes many of these issues by switching to a well known graph
132-
* data structure and algorithms to avoid many of the subtle bugs that plagued the legacy binding
133-
* graph factory. However, note that the new binding graph factory also has a behavior change that
134-
* could cause issues for some users. Specifically, a module binding is no longer allowed to float
135-
* from its installed component into one of its subcomponents in order to satisfy a missing
136-
* dependency. Thus, any (transitive) dependencies of the module binding that are missing from the
137-
* installed component will now be reported as an error.
127+
* <p>See https://dagger.dev/dev-guide/compiler-options#useBindingGraphFix for more details.
138128
*/
139-
public abstract boolean useLegacyBindingGraphFactory();
129+
public abstract boolean useBindingGraphFix();
140130

141131
/**
142132
* Returns {@code true} if the key for map multibinding contributions contain a framework type.

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
import static dagger.internal.codegen.compileroption.ProcessingEnvironmentCompilerOptions.Feature.PLUGINS_VISIT_FULL_BINDING_GRAPHS;
3535
import static dagger.internal.codegen.compileroption.ProcessingEnvironmentCompilerOptions.Feature.STRICT_MULTIBINDING_VALIDATION;
3636
import static dagger.internal.codegen.compileroption.ProcessingEnvironmentCompilerOptions.Feature.STRICT_SUPERFICIAL_VALIDATION;
37+
import static dagger.internal.codegen.compileroption.ProcessingEnvironmentCompilerOptions.Feature.USE_BINDING_GRAPH_FIX;
3738
import static dagger.internal.codegen.compileroption.ProcessingEnvironmentCompilerOptions.Feature.USE_FRAMEWORK_TYPE_IN_MAP_MULTIBINDING_CONTRIBUTION_KEY;
38-
import static dagger.internal.codegen.compileroption.ProcessingEnvironmentCompilerOptions.Feature.USE_LEGACY_BINDING_GRAPH_FACTORY;
3939
import static dagger.internal.codegen.compileroption.ProcessingEnvironmentCompilerOptions.Feature.VALIDATE_TRANSITIVE_COMPONENT_DEPENDENCIES;
4040
import static dagger.internal.codegen.compileroption.ProcessingEnvironmentCompilerOptions.Feature.WARN_IF_INJECTION_FACTORY_NOT_GENERATED_UPSTREAM;
4141
import static dagger.internal.codegen.compileroption.ProcessingEnvironmentCompilerOptions.Feature.WRITE_PRODUCER_NAME_IN_TOKEN;
@@ -205,8 +205,8 @@ public boolean generatedClassExtendsComponent() {
205205
}
206206

207207
@Override
208-
public boolean useLegacyBindingGraphFactory() {
209-
return isEnabled(USE_LEGACY_BINDING_GRAPH_FACTORY);
208+
public boolean useBindingGraphFix() {
209+
return isEnabled(USE_BINDING_GRAPH_FIX);
210210
}
211211

212212
@Override
@@ -342,7 +342,7 @@ enum Feature implements EnumOption<FeatureStatus> {
342342

343343
GENERATED_CLASS_EXTENDS_COMPONENT,
344344

345-
USE_LEGACY_BINDING_GRAPH_FACTORY(ENABLED),
345+
USE_BINDING_GRAPH_FIX,
346346

347347
USE_FRAMEWORK_TYPE_IN_MAP_MULTIBINDING_CONTRIBUTION_KEY,
348348

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ public boolean experimentalDaggerErrorMessages() {
112112
}
113113

114114
@Override
115-
public boolean useLegacyBindingGraphFactory() {
116-
return true;
115+
public boolean useBindingGraphFix() {
116+
return false;
117117
}
118118

119119
@Override

0 commit comments

Comments
 (0)