Fix regression test for null dynamic type in argument propagator
Change-Id: I86b20257e180be27d30ce63544bf591746b92078
diff --git a/src/main/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagatorCodeScanner.java b/src/main/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagatorCodeScanner.java
index e8287d3..aa82269 100644
--- a/src/main/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagatorCodeScanner.java
+++ b/src/main/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagatorCodeScanner.java
@@ -541,6 +541,7 @@
// TODO(b/331587404): Investigate if we can replace the receiver by null before entering this
// pass, so that this special case is not needed.
if (dynamicReceiverType.isNullType()) {
+ assert appView.testing().allowNullDynamicTypeInCodeScanner : "b/250634405";
// This can happen if we were unable to determine that the receiver is a phi value where null
// information has not been propagated down. Ideally this case would never happen as it should
// be possible to replace the receiver by the null constant in this case.
diff --git a/src/main/java/com/android/tools/r8/utils/InternalOptions.java b/src/main/java/com/android/tools/r8/utils/InternalOptions.java
index 3be695f..be887b7 100644
--- a/src/main/java/com/android/tools/r8/utils/InternalOptions.java
+++ b/src/main/java/com/android/tools/r8/utils/InternalOptions.java
@@ -2333,6 +2333,7 @@
public boolean allowClassInliningOfSynthetics = true;
public boolean allowInjectedAnnotationMethods = false;
public boolean allowInliningOfSynthetics = true;
+ public boolean allowNullDynamicTypeInCodeScanner = true;
public boolean allowTypeErrors =
!Version.isDevelopmentVersion()
|| System.getProperty("com.android.tools.r8.allowTypeErrors") != null;
diff --git a/src/test/java/com/android/tools/r8/optimize/argumentpropagation/PolymorphicMethodWithNullReceiverBoundTest.java b/src/test/java/com/android/tools/r8/optimize/argumentpropagation/PolymorphicMethodWithNullReceiverBoundTest.java
index 776cf11..45f163e 100644
--- a/src/test/java/com/android/tools/r8/optimize/argumentpropagation/PolymorphicMethodWithNullReceiverBoundTest.java
+++ b/src/test/java/com/android/tools/r8/optimize/argumentpropagation/PolymorphicMethodWithNullReceiverBoundTest.java
@@ -23,11 +23,11 @@
* This is an attempt on a regression test for b/250634405. What happens in the input program is
* that we determine a phi value to be always null in Phi.getDynamicUpperBoundType. That information
* has not been propagated to the receiver during optimizing of the IR. Therefor the check at {@link
- * ArgumentPropagatorCodeScanner.scan} for receiver always being null returns false.
+ * ArgumentPropagatorCodeScanner#scan} for receiver always being null returns false.
*
* <p>Getting the exact IR to match was difficult so this test short circuit this by disabling IR
* processing of a simple method (by specifying pass-through) and disabling the check in {@link
- * ArgumentPropagatorCodeScanner.scan}.
+ * ArgumentPropagatorCodeScanner#scan}.
*/
@RunWith(Parameterized.class)
public class PolymorphicMethodWithNullReceiverBoundTest extends TestBase {
@@ -44,24 +44,23 @@
public void testR8WithTestAssertionsEnabled() {
assertThrows(
CompilationFailedException.class,
- () -> {
- testForR8(parameters.getBackend())
- .addInnerClasses(getClass())
- .addKeepMainRule(Main.class)
- .enableNoHorizontalClassMergingAnnotations()
- .enableNoVerticalClassMergingAnnotations()
- .setMinApi(parameters)
- .addOptionsModification(
- options -> {
- options.testing.cfByteCodePassThrough =
- method -> method.getName().startsWith("main");
- options.testing.checkReceiverAlwaysNullInCallSiteOptimization = false;
- })
- .compileWithExpectedDiagnostics(
- diagnostics -> {
- diagnostics.assertErrorMessageThatMatches(containsString("b/250634405"));
- });
- });
+ () ->
+ testForR8(parameters.getBackend())
+ .addInnerClasses(getClass())
+ .addKeepMainRule(Main.class)
+ .enableNoHorizontalClassMergingAnnotations()
+ .enableNoVerticalClassMergingAnnotations()
+ .setMinApi(parameters)
+ .addOptionsModification(
+ options -> {
+ options.testing.allowNullDynamicTypeInCodeScanner = false;
+ options.testing.cfByteCodePassThrough =
+ method -> method.getName().startsWith("main");
+ options.testing.checkReceiverAlwaysNullInCallSiteOptimization = false;
+ })
+ .compileWithExpectedDiagnostics(
+ diagnostics ->
+ diagnostics.assertErrorMessageThatMatches(containsString("b/250634405"))));
}
@Test