FIR CFG: route to exit of try main for throw in try main
to make the remaining part of try main marked as dead. ^KT-45475 Fixed
This commit is contained in:
committed by
TeamCityServer
parent
7a7114f896
commit
922419efb8
+4
-4
@@ -1272,10 +1272,10 @@ class ControlFlowGraphBuilder {
|
|||||||
// (4)... in catch, i.e., re-throw.
|
// (4)... in catch, i.e., re-throw.
|
||||||
exitTargetsForTry.top()
|
exitTargetsForTry.top()
|
||||||
} else {
|
} else {
|
||||||
// (4)... in try-main. We already have:
|
// (4)... in try-main. Route to exit of try main block.
|
||||||
// edges from try-main enter node to each catch clause enter node and
|
// We already have edges from the exit of try main block to each catch clause.
|
||||||
// edges from catch clause enter node to exit target (w/ UncaughtExceptionPath)
|
// This edge makes the remaining part of try main block, e.g., following `when` branches, marked as dead.
|
||||||
return
|
tryMainExitNodes.top()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// (3)... within finally.
|
// (3)... within finally.
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// IGNORE_FIR_DIAGNOSTICS
|
||||||
// FILE: 1.kt
|
// FILE: 1.kt
|
||||||
class A(val s: String)
|
class A(val s: String)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,222 @@
|
|||||||
|
fun foo(): Int = 42
|
||||||
|
|
||||||
|
object ThrowInTryWithCatch {
|
||||||
|
private val p: String
|
||||||
|
|
||||||
|
init {
|
||||||
|
try {
|
||||||
|
throw Exception()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
}
|
||||||
|
p = "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object ThrowInTryWithCatchAndFinally {
|
||||||
|
private val p: String
|
||||||
|
|
||||||
|
init {
|
||||||
|
try {
|
||||||
|
throw Exception()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
} finally {
|
||||||
|
}
|
||||||
|
p = "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object ThrowInFinally {
|
||||||
|
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>private val p: String<!>
|
||||||
|
|
||||||
|
init {
|
||||||
|
try {
|
||||||
|
foo()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
} finally {
|
||||||
|
throw Exception()
|
||||||
|
}
|
||||||
|
p = "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object RethrowInCatch {
|
||||||
|
private val p: String
|
||||||
|
|
||||||
|
init {
|
||||||
|
try {
|
||||||
|
foo()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
p = "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object RethrowInCatchWithFinally {
|
||||||
|
private val p: String
|
||||||
|
|
||||||
|
init {
|
||||||
|
try {
|
||||||
|
foo()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
throw e
|
||||||
|
} finally {
|
||||||
|
}
|
||||||
|
p = "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object InnerTryWithCatch {
|
||||||
|
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>private val p: String<!>
|
||||||
|
|
||||||
|
init {
|
||||||
|
try {
|
||||||
|
foo()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
try {
|
||||||
|
throw e
|
||||||
|
} catch (ee: Exception) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p = "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object InnerTryWithFinally {
|
||||||
|
private val p: String
|
||||||
|
|
||||||
|
init {
|
||||||
|
try {
|
||||||
|
foo()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
try {
|
||||||
|
throw e
|
||||||
|
} finally {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p = "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
object InnerTryWithCatchAndFinally {
|
||||||
|
private val p: String
|
||||||
|
|
||||||
|
init {
|
||||||
|
try {
|
||||||
|
foo()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
try {
|
||||||
|
throw e
|
||||||
|
} catch (ee: Exception) {
|
||||||
|
} finally {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p = "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object InnerCatch {
|
||||||
|
private val p: String
|
||||||
|
|
||||||
|
init {
|
||||||
|
try {
|
||||||
|
foo()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
try {
|
||||||
|
foo()
|
||||||
|
} catch (ee: Exception) {
|
||||||
|
throw ee
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p = "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object InnerCatchWithFinally {
|
||||||
|
private val p: String
|
||||||
|
|
||||||
|
init {
|
||||||
|
try {
|
||||||
|
foo()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
try {
|
||||||
|
foo()
|
||||||
|
} catch (ee: Exception) {
|
||||||
|
throw ee
|
||||||
|
} finally {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p = "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object InnerCatchOuterRethrow {
|
||||||
|
private val p: String
|
||||||
|
|
||||||
|
init {
|
||||||
|
try {
|
||||||
|
foo()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
try {
|
||||||
|
foo()
|
||||||
|
} catch (ee: Exception) {
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p = "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object InnerCatchOuterRethrowWithFinally {
|
||||||
|
private val p: String
|
||||||
|
|
||||||
|
init {
|
||||||
|
try {
|
||||||
|
foo()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
try {
|
||||||
|
foo()
|
||||||
|
} catch (ee: Exception) {
|
||||||
|
throw e
|
||||||
|
} finally {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p = "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object InnerFinally {
|
||||||
|
private val p: String
|
||||||
|
|
||||||
|
init {
|
||||||
|
try {
|
||||||
|
foo()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
try {
|
||||||
|
foo()
|
||||||
|
} finally {
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p = "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object InnerFinallyWithCatch {
|
||||||
|
private val p: String
|
||||||
|
|
||||||
|
init {
|
||||||
|
try {
|
||||||
|
foo()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
try {
|
||||||
|
foo()
|
||||||
|
} catch (ee: Exception) {
|
||||||
|
} finally {
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p = "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
// FIR_IDENTICAL
|
|
||||||
fun foo(): Int = 42
|
fun foo(): Int = 42
|
||||||
|
|
||||||
object ThrowInTryWithCatch {
|
object ThrowInTryWithCatch {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ fun conditionalThrowInTry_smartcastInTry(a: A) {
|
|||||||
if (a !is B) {
|
if (a !is B) {
|
||||||
throw AssertionError()
|
throw AssertionError()
|
||||||
}
|
}
|
||||||
<!INAPPLICABLE_CANDIDATE!>takeB<!>(a)
|
takeB(a)
|
||||||
} catch (e: Throwable) {}
|
} catch (e: Throwable) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user