Limit upward propagation of assume* rules to first implementer.

Bug: 137938214
Change-Id: If4ad137c915b9a2e534dc5f3e4fc3c5c0fe1333c
diff --git a/src/main/java/com/android/tools/r8/shaking/RootSetBuilder.java b/src/main/java/com/android/tools/r8/shaking/RootSetBuilder.java
index 1693ed7..8e07cc1 100644
--- a/src/main/java/com/android/tools/r8/shaking/RootSetBuilder.java
+++ b/src/main/java/com/android/tools/r8/shaking/RootSetBuilder.java
@@ -182,21 +182,25 @@
           markClass(clazz, rule, ifRule);
         } else {
           preconditionSupplier = ImmutableMap.of((definition -> true), clazz);
-          markMatchingVisibleMethods(clazz, memberKeepRules, rule, preconditionSupplier, true, ifRule);
+          markMatchingVisibleMethods(
+              clazz, memberKeepRules, rule, preconditionSupplier, true, ifRule);
           markMatchingOverriddenMethods(
               appView.appInfo(), clazz, memberKeepRules, rule, preconditionSupplier, true, ifRule);
-          markMatchingVisibleFields(clazz, memberKeepRules, rule, preconditionSupplier, true, ifRule);
+          markMatchingVisibleFields(
+              clazz, memberKeepRules, rule, preconditionSupplier, true, ifRule);
         }
       } else if (rule instanceof ProguardWhyAreYouKeepingRule) {
         markClass(clazz, rule, ifRule);
         markMatchingVisibleMethods(clazz, memberKeepRules, rule, null, true, ifRule);
-        markMatchingOverriddenMethods(appView.appInfo(), clazz, memberKeepRules, rule, null, true, ifRule);
+        markMatchingOverriddenMethods(
+            appView.appInfo(), clazz, memberKeepRules, rule, null, true, ifRule);
         markMatchingVisibleFields(clazz, memberKeepRules, rule, null, true, ifRule);
       } else if (rule instanceof ProguardAssumeMayHaveSideEffectsRule
           || rule instanceof ProguardAssumeNoSideEffectRule
           || rule instanceof ProguardAssumeValuesRule) {
         markMatchingVisibleMethods(clazz, memberKeepRules, rule, null, true, ifRule);
-        markMatchingOverriddenMethods(appView.appInfo(), clazz, memberKeepRules, rule, null, true, ifRule);
+        markMatchingOverriddenMethods(
+            appView.appInfo(), clazz, memberKeepRules, rule, null, true, ifRule);
         markMatchingVisibleFields(clazz, memberKeepRules, rule, null, true, ifRule);
       } else if (rule instanceof ClassMergingRule) {
         if (allRulesSatisfied(memberKeepRules, clazz)) {
@@ -588,8 +592,7 @@
       boolean includeLibraryClasses,
       ProguardIfRule ifRule) {
     Set<Wrapper<DexMethod>> methodsMarked =
-        options.forceProguardCompatibility || rule instanceof ProguardAssumeNoSideEffectRule
-            ? null : new HashSet<>();
+        options.forceProguardCompatibility ? null : new HashSet<>();
     DexClass startingClass = clazz;
     while (clazz != null) {
       if (!includeLibraryClasses && clazz.isNotProgramClass()) {
diff --git a/src/test/java/com/android/tools/r8/shaking/assumenosideeffects/AssumenosideeffectsVisibleMethodsTest.java b/src/test/java/com/android/tools/r8/shaking/assumenosideeffects/AssumenosideeffectsVisibleMethodsTest.java
index a9dda0d..24edc40 100644
--- a/src/test/java/com/android/tools/r8/shaking/assumenosideeffects/AssumenosideeffectsVisibleMethodsTest.java
+++ b/src/test/java/com/android/tools/r8/shaking/assumenosideeffects/AssumenosideeffectsVisibleMethodsTest.java
@@ -80,10 +80,8 @@
               "The end");
         case RULE_THAT_REFERS_PRG_BASE:
           return StringUtils.lines(
-              // TODO(b/137938214): Should not mark LibraryBase's methods.
-              // "Throwing!",
-              "Unless LibraryBase is explicitly mentioned",
-              // "[LibraryBase]: as long as LibraryBase is specified"
+              "Expect to catch RuntimeException",
+              "[LibraryBase]: as long as LibraryBase is specified",
               // TODO(b/137938214): Should we mark ProgramSub's methods?
               //   Those are clearly an instance of ProgramSub type, and invocations with it.
               //   One caveat: ProgramSub#throwing doesn't exist, so ProgramBase#throwing will be
@@ -92,26 +90,22 @@
               "The end");
         case RULE_THAT_REFERS_PRG_SUB:
           return StringUtils.lines(
-              // TODO(b/137938214): Should not mark LibraryBase's methods.
-              // "Throwing!",
-              "Unless LibraryBase is explicitly mentioned",
-              // TODO(b/137938214): Should not mark *Base's #debug(...)
-              // "[LibraryBase]: as long as LibraryBase is specified"
+              "Expect to catch RuntimeException",
+              "[LibraryBase]: as long as LibraryBase is specified",
+              // TODO(b/137938214): Should we do synthetic propagation up to ProgramBase#debug() ?
               // "[ProgramBase]: as long as ProgramBase is specified"
               "The end");
         case RULE_WITH_EXTENDS_LIB_BASE:
           return StringUtils.lines(
-              // TODO(b/137938214): Should not mark LibraryBase's methods.
-              // "Throwing!",
-              "Unless LibraryBase is explicitly mentioned",
-              // "[LibraryBase]: as long as LibraryBase is specified"
+              "Expect to catch RuntimeException",
+              "[LibraryBase]: as long as LibraryBase is specified",
               "The end");
         case RULE_WITH_EXTENDS_PRG_BASE:
           return StringUtils.lines(
-              // TODO(b/137938214): Should not mark LibraryBase's methods.
-              // "Throwing!",
-              "Unless LibraryBase is explicitly mentioned",
-              // "[LibraryBase]: as long as LibraryBase is specified"
+              "Expect to catch RuntimeException",
+              "[LibraryBase]: as long as LibraryBase is specified",
+              // TODO(b/137938214): Should we do synthetic propagation up to ProgramBase#debug() ?
+              // "[ProgramBase]: as long as ProgramBase is specified"
               "The end");
       }
       throw new Unreachable();