commit | 8feec5d7abb33bf6d455d10389b9bed688f87553 | [log] [tgz] |
---|---|---|
author | Christoffer Quist Adamsen <christofferqa@google.com> | Wed May 31 11:19:58 2023 +0200 |
committer | Christoffer Quist Adamsen <christofferqa@google.com> | Wed May 31 11:19:58 2023 +0200 |
tree | 0377c38e56800aa1c09b843e5beec2e29a587bbf | |
parent | fcc40146761d8bec9ac1c00a29c34bb5a50dfe0e [diff] |
Fix inadequate argument propagation in presence of join types Bug: b/284188592 Change-Id: Ic00ce43da9839884cbb19a87a7b43020951c3114
diff --git a/src/main/java/com/android/tools/r8/optimize/argumentpropagation/propagation/VirtualDispatchMethodArgumentPropagator.java b/src/main/java/com/android/tools/r8/optimize/argumentpropagation/propagation/VirtualDispatchMethodArgumentPropagator.java index a1aec5a..313b6ca 100644 --- a/src/main/java/com/android/tools/r8/optimize/argumentpropagation/propagation/VirtualDispatchMethodArgumentPropagator.java +++ b/src/main/java/com/android/tools/r8/optimize/argumentpropagation/propagation/VirtualDispatchMethodArgumentPropagator.java
@@ -170,7 +170,14 @@ && currentClass.getSuperType() != appView.dexItemFactory().objectType) { return classType.lessThanOrEqualUpToNullability(upperBound, appView); } - return classType.equalUpToNullability(upperBound); + // If the upper bound does not have any interfaces we simply activate the method state when + // meeting the upper bound class type in the downwards traversal over the class hierarchy. + if (classType.getInterfaces().isEmpty()) { + return classType.equalUpToNullability(upperBound); + } + // If the upper bound has interfaces, we check if the current class is a subtype of *both* the + // upper bound class type and the upper bound interface types. + return classType.lessThanOrEqualUpToNullability(upperBound, appView); } }
diff --git a/src/test/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagationUpperBoundWithInterfacesTest.java b/src/test/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagationUpperBoundWithInterfacesTest.java index 1c1e45a..7ac6f56 100644 --- a/src/test/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagationUpperBoundWithInterfacesTest.java +++ b/src/test/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagationUpperBoundWithInterfacesTest.java
@@ -45,8 +45,7 @@ .setMinApi(parameters) .compile() .run(parameters.getRuntime(), Main.class) - // TODO(b/284188592): Should succeed with "42". - .assertFailureWithErrorThatThrows(NullPointerException.class); + .assertSuccessWithOutputLines("42"); } static class Main {