commit | 1a6b23bd5d97a0ff2a6464d1921455f6b3b0d740 | [log] [tgz] |
---|---|---|
author | Christoffer Quist Adamsen <christofferqa@google.com> | Tue May 30 12:57:51 2023 +0200 |
committer | Christoffer Quist Adamsen <christofferqa@google.com> | Tue May 30 12:57:51 2023 +0200 |
tree | bc27953512cfccc0af6c070f16851116dea7150c | |
parent | 3c496ba2ac10dbf6f8870671f92336969893ca15 [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 {