17a1871b83
The primary constructor of a class needs to be the first subgraph of the class control-flow graph. Based on the Kotlin specification, class initialization order goes first primary constructor, in-place declarations (properties and init blocks), and then secondary constructors. If the class doesn't have a primary constructor, then it is just skipped in the order. Unfortunately, the class control-flow graph had in-place declarations first and then all constructors. Instead, we should treat the primary constructor as the first in-place declaration, and then continue with the existing processing as secondary constructors. This will guarantee that super constructor calls have the correct property initialization information. ^KT-65093 Fixed
225 lines
3.6 KiB
Kotlin
Vendored
225 lines
3.6 KiB
Kotlin
Vendored
// FIR_IDENTICAL
|
|
|
|
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 {
|
|
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"
|
|
}
|
|
}
|