Skip to content

Commit

Permalink
Do not turn on fast init mode when experimental mode is on.
Browse files Browse the repository at this point in the history
RELNOTES=n/a
PiperOrigin-RevId: 411666815
  • Loading branch information
wanyingd1996 authored and Dagger Team committed Nov 22, 2021
1 parent e32f9c6 commit 9b44b19
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
14 changes: 13 additions & 1 deletion java/dagger/internal/codegen/compileroption/CompilerOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,19 @@ public abstract class CompilerOptions {
* <p>Issues related to this flag will not be supported. This flag could break your build, cause
* memory leaks in your app, or cause other unknown issues at runtime.
*/
public abstract boolean experimentalMergedMode();
public final boolean experimentalMergedMode(XTypeElement element) {
return experimentalMergedMode(toJavac(element));
}

/**
* Returns true if the experimental Android mode is enabled.
*
* <p><b>Warning: Do Not use! This flag is for internal, experimental use only!</b>
*
* <p>Issues related to this flag will not be supported. This flag could break your build, cause
* memory leaks in your app, or cause other unknown issues at runtime.
*/
public abstract boolean experimentalMergedMode(TypeElement element);

/**
* Returns true if the fast initialization flag, {@code fastInit}, is enabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static com.google.common.base.CaseFormat.LOWER_CAMEL;
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.Sets.immutableEnumSet;
import static dagger.internal.codegen.compileroption.FeatureStatus.DISABLED;
import static dagger.internal.codegen.compileroption.FeatureStatus.ENABLED;
Expand Down Expand Up @@ -100,15 +101,37 @@ public boolean headerCompilation() {
}

@Override
public boolean experimentalMergedMode() {
return false;
public boolean experimentalMergedMode(TypeElement component) {
boolean isExperimental = experimentalMergedModeInternal();
if (isExperimental) {
checkState(
!fastInitInternal(component),
"Both fast init and experimental merged mode were turned on, please specify exactly one"
+ " compilation mode.");
}
return isExperimental;
}

@Override
public boolean fastInit(TypeElement component) {
boolean isFastInit = fastInitInternal(component);
if (isFastInit) {
checkState(
!experimentalMergedModeInternal(),
"Both fast init and experimental merged mode were turned on, please specify exactly one"
+ " compilation mode.");
}
return isFastInit;
}

private boolean fastInitInternal(TypeElement component) {
return isEnabled(FAST_INIT);
}

private boolean experimentalMergedModeInternal() {
return false;
}

@Override
public boolean formatGeneratedSource() {
return isEnabled(FORMAT_GENERATED_SOURCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public boolean usesProducers() {
}

@Override
public boolean experimentalMergedMode() {
public boolean experimentalMergedMode(TypeElement element) {
return false;
}

Expand Down

0 comments on commit 9b44b19

Please sign in to comment.