Don't assume fixed return values if there are throwing instructions

Bug: b/371247958
Change-Id: I446c9649e086e8ae3a61b7382aedd16f28756693
diff --git a/src/main/java/com/android/tools/r8/ir/analysis/inlining/SimpleInliningConstraintAnalysis.java b/src/main/java/com/android/tools/r8/ir/analysis/inlining/SimpleInliningConstraintAnalysis.java
index de956ca..fa31549 100644
--- a/src/main/java/com/android/tools/r8/ir/analysis/inlining/SimpleInliningConstraintAnalysis.java
+++ b/src/main/java/com/android/tools/r8/ir/analysis/inlining/SimpleInliningConstraintAnalysis.java
@@ -93,7 +93,10 @@
       int branchDepth,
       int instructionDepth,
       InstructionIterator instructionIterator) {
-    if (!seen.add(block) || block.hasCatchHandlers() || branchDepth > MAX_BRANCH_DEPTH) {
+    if (!seen.add(block)
+        || block.hasCatchHandlers()
+        || block.exit().isThrow()
+        || branchDepth > MAX_BRANCH_DEPTH) {
       return SimpleInliningConstraintWithDepth.getNever();
     }
 
diff --git a/src/test/java/com/android/tools/r8/regress/Regress371247958.java b/src/test/java/com/android/tools/r8/regress/Regress371247958.java
index 96fc07d..2fc1e61 100644
--- a/src/test/java/com/android/tools/r8/regress/Regress371247958.java
+++ b/src/test/java/com/android/tools/r8/regress/Regress371247958.java
@@ -32,8 +32,7 @@
         .setMinApi(parameters)
         .compile()
         .run(parameters.getRuntime(), TestClass.class)
-        // TODO(b/371247958): Should throw a RuntimeException
-        .assertSuccess();
+        .assertFailureWithErrorThatThrows(RuntimeException.class);
   }
 
   @Test
@@ -55,7 +54,7 @@
     }
 
     public static void main(String[] p) throws Exception {
-      throwException(new RuntimeException("always thrown"), false);
+      System.out.println(throwException(new RuntimeException("always thrown"), false));
     }
   }
 }