Reproduce KT-45385: false positive MUST_BE_INITIALIZED_* after rethrow
This commit is contained in:
committed by
TeamCityServer
parent
f4c63c8ba2
commit
4f20d2dccf
+6
@@ -362,6 +362,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/InfixModifierApplicability.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("initializedAfterRethrow.kt")
|
||||
public void testInitializedAfterRethrow() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/initializedAfterRethrow.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("InvokeAndRecursiveResolve.kt")
|
||||
public void testInvokeAndRecursiveResolve() throws Exception {
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
fun foo(): Int = 42
|
||||
|
||||
object ThrowInTryWithCatch {
|
||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>private val p: String<!>
|
||||
|
||||
init {
|
||||
try {
|
||||
throw Exception()
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
p = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
object ThrowInTryWithCatchAndFinally {
|
||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>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 {
|
||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>private val p: String<!>
|
||||
|
||||
init {
|
||||
try {
|
||||
foo()
|
||||
} catch (e: Exception) {
|
||||
throw e
|
||||
}
|
||||
p = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
object RethrowInCatchWithFinally {
|
||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>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 {
|
||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>private val p: String<!>
|
||||
|
||||
init {
|
||||
try {
|
||||
foo()
|
||||
} catch (e: Exception) {
|
||||
try {
|
||||
throw e
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
p = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
object InnerTryWithCatchAndFinally {
|
||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>private val p: String<!>
|
||||
|
||||
init {
|
||||
try {
|
||||
foo()
|
||||
} catch (e: Exception) {
|
||||
try {
|
||||
throw e
|
||||
} catch (ee: Exception) {
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
p = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
object InnerCatch {
|
||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>private val p: String<!>
|
||||
|
||||
init {
|
||||
try {
|
||||
foo()
|
||||
} catch (e: Exception) {
|
||||
try {
|
||||
foo()
|
||||
} catch (ee: Exception) {
|
||||
throw ee
|
||||
}
|
||||
}
|
||||
p = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
object InnerCatchWithFinally {
|
||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>private val p: String<!>
|
||||
|
||||
init {
|
||||
try {
|
||||
foo()
|
||||
} catch (e: Exception) {
|
||||
try {
|
||||
foo()
|
||||
} catch (ee: Exception) {
|
||||
throw ee
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
p = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
object InnerCatchOuterRethrow {
|
||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>private val p: String<!>
|
||||
|
||||
init {
|
||||
try {
|
||||
foo()
|
||||
} catch (e: Exception) {
|
||||
try {
|
||||
foo()
|
||||
} catch (ee: Exception) {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
p = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
object InnerCatchOuterRethrowWithFinally {
|
||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>private val p: String<!>
|
||||
|
||||
init {
|
||||
try {
|
||||
foo()
|
||||
} catch (e: Exception) {
|
||||
try {
|
||||
foo()
|
||||
} catch (ee: Exception) {
|
||||
throw e
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
p = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
object InnerFinally {
|
||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>private val p: String<!>
|
||||
|
||||
init {
|
||||
try {
|
||||
foo()
|
||||
} catch (e: Exception) {
|
||||
try {
|
||||
foo()
|
||||
} finally {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
p = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
object InnerFinallyWithCatch {
|
||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>private val p: String<!>
|
||||
|
||||
init {
|
||||
try {
|
||||
foo()
|
||||
} catch (e: Exception) {
|
||||
try {
|
||||
foo()
|
||||
} catch (ee: Exception) {
|
||||
} finally {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
p = "OK"
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
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"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package
|
||||
|
||||
public fun foo(): kotlin.Int
|
||||
|
||||
public object InnerCatch {
|
||||
private constructor InnerCatch()
|
||||
private final val p: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object InnerCatchOuterRethrow {
|
||||
private constructor InnerCatchOuterRethrow()
|
||||
private final val p: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object InnerCatchOuterRethrowWithFinally {
|
||||
private constructor InnerCatchOuterRethrowWithFinally()
|
||||
private final val p: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object InnerCatchWithFinally {
|
||||
private constructor InnerCatchWithFinally()
|
||||
private final val p: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object InnerFinally {
|
||||
private constructor InnerFinally()
|
||||
private final val p: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object InnerFinallyWithCatch {
|
||||
private constructor InnerFinallyWithCatch()
|
||||
private final val p: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object InnerTryWithCatch {
|
||||
private constructor InnerTryWithCatch()
|
||||
private final val p: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object InnerTryWithCatchAndFinally {
|
||||
private constructor InnerTryWithCatchAndFinally()
|
||||
private final val p: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object InnerTryWithFinally {
|
||||
private constructor InnerTryWithFinally()
|
||||
private final val p: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object RethrowInCatch {
|
||||
private constructor RethrowInCatch()
|
||||
private final val p: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object RethrowInCatchWithFinally {
|
||||
private constructor RethrowInCatchWithFinally()
|
||||
private final val p: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object ThrowInFinally {
|
||||
private constructor ThrowInFinally()
|
||||
private final val p: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object ThrowInTryWithCatch {
|
||||
private constructor ThrowInTryWithCatch()
|
||||
private final val p: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object ThrowInTryWithCatchAndFinally {
|
||||
private constructor ThrowInTryWithCatchAndFinally()
|
||||
private final val p: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
Generated
+6
@@ -362,6 +362,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/InfixModifierApplicability.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("initializedAfterRethrow.kt")
|
||||
public void testInitializedAfterRethrow() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/initializedAfterRethrow.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("InvokeAndRecursiveResolve.kt")
|
||||
public void testInvokeAndRecursiveResolve() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user