Reland "Use isShrinkingAllowed in GenericSignatureCorrectnessHelper"
This reverts commit 45912bee8b2ff6f51b3b08b4010ab4001c4be2f8.
Change-Id: Ic47481253f053c1ba6d2215c09c561bfd0c3ed21
diff --git a/src/main/java/com/android/tools/r8/graph/GenericSignatureCorrectnessHelper.java b/src/main/java/com/android/tools/r8/graph/GenericSignatureCorrectnessHelper.java
index 8aaf078..d8c3142 100644
--- a/src/main/java/com/android/tools/r8/graph/GenericSignatureCorrectnessHelper.java
+++ b/src/main/java/com/android/tools/r8/graph/GenericSignatureCorrectnessHelper.java
@@ -21,6 +21,9 @@
import com.android.tools.r8.graph.GenericSignature.ReturnType;
import com.android.tools.r8.graph.GenericSignature.TypeSignature;
import com.android.tools.r8.graph.GenericSignatureContextBuilder.TypeParameterContext;
+import com.android.tools.r8.shaking.KeepClassInfo;
+import com.android.tools.r8.shaking.KeepFieldInfo;
+import com.android.tools.r8.shaking.KeepMethodInfo;
import com.android.tools.r8.utils.ListUtils;
import java.util.List;
import java.util.function.Consumer;
@@ -127,7 +130,12 @@
SignatureEvaluationResult result =
genericSignatureContextEvaluator.evaluateClassSignatureForContext(typeParameterContext);
if (result.isInvalid() && mode.clearIfInvalid()) {
- if (appView.hasLiveness() && appView.getKeepInfo().getClassInfo(clazz).isPinned()) {
+ // Only report info messages for classes that are kept explicitly. This is to ensure we do not
+ // spam the developer with messages they can do nothing about.
+ KeepClassInfo classInfo = appView.getKeepInfo().getClassInfo(clazz);
+ if (appView.hasLiveness() && !classInfo.isShrinkingAllowed(appView.options())) {
+ // If/when this no longer holds it should be moved into the condition.
+ assert !classInfo.isSignatureAttributeRemovalAllowed(appView.options());
appView
.options()
.reporter
@@ -149,8 +157,13 @@
genericSignatureContextEvaluator.visitMethodSignature(
methodSignature, typeParameterContext),
invalidResult -> {
+ // Only report info messages for methods that are kept explicitly. This is to
+ // ensure we do not spam the developer with messages they can do nothing about.
+ KeepMethodInfo methodInfo = appView.getKeepInfo().getMethodInfo(method, clazz);
if (appView.hasLiveness()
- && appView.getKeepInfo().getMethodInfo(method, clazz).isPinned()) {
+ && !methodInfo.isShrinkingAllowed(appView.options())) {
+ // If/when this no longer holds it should be moved into the condition.
+ assert !methodInfo.isSignatureAttributeRemovalAllowed(appView.options());
appView
.options()
.reporter
@@ -173,8 +186,12 @@
genericSignatureContextEvaluator.visitFieldTypeSignature(
fieldSignature, typeParameterContext),
invalidResult -> {
- if (appView.hasLiveness()
- && appView.getKeepInfo().getFieldInfo(field, clazz).isPinned()) {
+ KeepFieldInfo fieldInfo = appView.getKeepInfo().getFieldInfo(field, clazz);
+ // Only report info messages for fields that are kept explicitly. This is to
+ // ensure we do not spam the developer with messages they can do nothing about.
+ if (appView.hasLiveness() && !fieldInfo.isShrinkingAllowed(appView.options())) {
+ // If/when this no longer holds it should be moved into the condition.
+ assert !fieldInfo.isSignatureAttributeRemovalAllowed(appView.options());
appView
.options()
.reporter
diff --git a/src/test/java/com/android/tools/r8/graph/genericsignature/GenericSignatureCorrectnessHelperTests.java b/src/test/java/com/android/tools/r8/graph/genericsignature/GenericSignatureCorrectnessHelperTests.java
index 59460b6..588ad23 100644
--- a/src/test/java/com/android/tools/r8/graph/genericsignature/GenericSignatureCorrectnessHelperTests.java
+++ b/src/test/java/com/android/tools/r8/graph/genericsignature/GenericSignatureCorrectnessHelperTests.java
@@ -18,6 +18,7 @@
import com.android.tools.r8.graph.GenericSignatureContextBuilder;
import com.android.tools.r8.graph.GenericSignatureCorrectnessHelper;
import com.android.tools.r8.graph.GenericSignatureCorrectnessHelper.SignatureEvaluationResult;
+import com.android.tools.r8.shaking.AppInfoWithLiveness;
import com.android.tools.r8.shaking.ProguardConfiguration;
import com.android.tools.r8.shaking.ProguardKeepAttributes;
import com.android.tools.r8.transformers.ClassFileTransformer.MethodPredicate;
@@ -188,8 +189,8 @@
Class<?> classToVerify,
SignatureEvaluationResult expected)
throws Exception {
- AppView<AppInfoWithClassHierarchy> appView =
- computeAppViewWithClassHierarchy(
+ AppView<AppInfoWithLiveness> appView =
+ computeAppViewWithLiveness(
buildClasses(classes)
.addClassProgramData(transformations)
.addLibraryFile(ToolHelper.getJava8RuntimeJar())