Reproduce KT-45475: no smartcast after conditional throw in try expression
This commit is contained in:
committed by
TeamCityServer
parent
1f6f996faf
commit
7e5b562b33
+6
@@ -25745,6 +25745,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
runTest("compiler/testData/diagnostics/tests/smartCasts/threeImplicitReceivers.kt");
|
runTest("compiler/testData/diagnostics/tests/smartCasts/threeImplicitReceivers.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("throwInTry.kt")
|
||||||
|
public void testThrowInTry() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/smartCasts/throwInTry.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("twoImplicitReceivers.kt")
|
@TestMetadata("twoImplicitReceivers.kt")
|
||||||
public void testTwoImplicitReceivers() throws Exception {
|
public void testTwoImplicitReceivers() throws Exception {
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_EXPRESSION
|
||||||
|
|
||||||
|
fun throwInTry_valueInCatch_smartcastAfterTryCatch() {
|
||||||
|
val s = try {
|
||||||
|
throw AssertionError()
|
||||||
|
} catch(e: Throwable) {
|
||||||
|
"OK"
|
||||||
|
}
|
||||||
|
s.length
|
||||||
|
}
|
||||||
|
|
||||||
|
fun throwInTry_valueInFinally_noSmartcastAfterTryCatchFinally() {
|
||||||
|
val s = try {
|
||||||
|
throw AssertionError()
|
||||||
|
} catch(e: Throwable) {
|
||||||
|
} finally {
|
||||||
|
"not enough"
|
||||||
|
}
|
||||||
|
s.<!UNRESOLVED_REFERENCE!>length<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
fun throwInTry_valueInCatchAndFinally_smartcastAfterTryCatchFinally() {
|
||||||
|
val s = try {
|
||||||
|
throw AssertionError()
|
||||||
|
} catch(e: Throwable) {
|
||||||
|
"OK"
|
||||||
|
} finally {
|
||||||
|
"really"
|
||||||
|
}
|
||||||
|
s.length
|
||||||
|
}
|
||||||
|
|
||||||
|
interface A
|
||||||
|
interface B : A
|
||||||
|
|
||||||
|
fun takeB(b: B) {}
|
||||||
|
|
||||||
|
fun conditionalThrowInTry_smartcastInTry(a: A) {
|
||||||
|
try {
|
||||||
|
if (a !is B) {
|
||||||
|
throw AssertionError()
|
||||||
|
}
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>takeB<!>(a)
|
||||||
|
} catch (e: Throwable) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun conditionalThrowInTry_noSmartcastAfterTryCatch(a: A) {
|
||||||
|
try {
|
||||||
|
if (a !is B) {
|
||||||
|
throw AssertionError()
|
||||||
|
}
|
||||||
|
} catch (e: Throwable) {}
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>takeB<!>(a)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun conditionalThrowInTry_rethrow_smartcastAfterTryCatch(a: A) {
|
||||||
|
try {
|
||||||
|
if (a !is B) {
|
||||||
|
throw AssertionError()
|
||||||
|
}
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>takeB<!>(a)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun conditionalThrowInTry_rethrow_smartcastAfterTryCatchFinally(a: A) {
|
||||||
|
try {
|
||||||
|
if (a !is B) {
|
||||||
|
throw AssertionError()
|
||||||
|
}
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
throw e
|
||||||
|
} finally {}
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>takeB<!>(a)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun conditionalThrowInTry_rethrow_noSmartcastInFinally(a: A) {
|
||||||
|
try {
|
||||||
|
if (a !is B) {
|
||||||
|
throw AssertionError()
|
||||||
|
}
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
throw e
|
||||||
|
} finally {
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>takeB<!>(a)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_EXPRESSION
|
||||||
|
|
||||||
|
fun throwInTry_valueInCatch_smartcastAfterTryCatch() {
|
||||||
|
val s = try {
|
||||||
|
throw AssertionError()
|
||||||
|
} catch(e: Throwable) {
|
||||||
|
"OK"
|
||||||
|
}
|
||||||
|
s.length
|
||||||
|
}
|
||||||
|
|
||||||
|
fun throwInTry_valueInFinally_noSmartcastAfterTryCatchFinally() {
|
||||||
|
val s = try {
|
||||||
|
throw AssertionError()
|
||||||
|
} catch(e: Throwable) {
|
||||||
|
} finally {
|
||||||
|
"not enough"
|
||||||
|
}
|
||||||
|
s.<!UNRESOLVED_REFERENCE!>length<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
fun throwInTry_valueInCatchAndFinally_smartcastAfterTryCatchFinally() {
|
||||||
|
val s = try {
|
||||||
|
throw AssertionError()
|
||||||
|
} catch(e: Throwable) {
|
||||||
|
"OK"
|
||||||
|
} finally {
|
||||||
|
"really"
|
||||||
|
}
|
||||||
|
s.length
|
||||||
|
}
|
||||||
|
|
||||||
|
interface A
|
||||||
|
interface B : A
|
||||||
|
|
||||||
|
fun takeB(b: B) {}
|
||||||
|
|
||||||
|
fun conditionalThrowInTry_smartcastInTry(a: A) {
|
||||||
|
try {
|
||||||
|
if (a !is B) {
|
||||||
|
throw AssertionError()
|
||||||
|
}
|
||||||
|
takeB(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||||
|
} catch (e: Throwable) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun conditionalThrowInTry_noSmartcastAfterTryCatch(a: A) {
|
||||||
|
try {
|
||||||
|
if (a !is B) {
|
||||||
|
throw AssertionError()
|
||||||
|
}
|
||||||
|
} catch (e: Throwable) {}
|
||||||
|
takeB(<!TYPE_MISMATCH!>a<!>)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun conditionalThrowInTry_rethrow_smartcastAfterTryCatch(a: A) {
|
||||||
|
try {
|
||||||
|
if (a !is B) {
|
||||||
|
throw AssertionError()
|
||||||
|
}
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
takeB(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun conditionalThrowInTry_rethrow_smartcastAfterTryCatchFinally(a: A) {
|
||||||
|
try {
|
||||||
|
if (a !is B) {
|
||||||
|
throw AssertionError()
|
||||||
|
}
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
throw e
|
||||||
|
} finally {}
|
||||||
|
takeB(<!TYPE_MISMATCH!>a<!>)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun conditionalThrowInTry_rethrow_noSmartcastInFinally(a: A) {
|
||||||
|
try {
|
||||||
|
if (a !is B) {
|
||||||
|
throw AssertionError()
|
||||||
|
}
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
throw e
|
||||||
|
} finally {
|
||||||
|
takeB(<!TYPE_MISMATCH!>a<!>)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun conditionalThrowInTry_noSmartcastAfterTryCatch(/*0*/ a: A): kotlin.Unit
|
||||||
|
public fun conditionalThrowInTry_rethrow_noSmartcastInFinally(/*0*/ a: A): kotlin.Unit
|
||||||
|
public fun conditionalThrowInTry_rethrow_smartcastAfterTryCatch(/*0*/ a: A): kotlin.Unit
|
||||||
|
public fun conditionalThrowInTry_rethrow_smartcastAfterTryCatchFinally(/*0*/ a: A): kotlin.Unit
|
||||||
|
public fun conditionalThrowInTry_smartcastInTry(/*0*/ a: A): kotlin.Unit
|
||||||
|
public fun takeB(/*0*/ b: B): kotlin.Unit
|
||||||
|
public fun throwInTry_valueInCatchAndFinally_smartcastAfterTryCatchFinally(): kotlin.Unit
|
||||||
|
public fun throwInTry_valueInCatch_smartcastAfterTryCatch(): kotlin.Unit
|
||||||
|
public fun throwInTry_valueInFinally_noSmartcastAfterTryCatchFinally(): kotlin.Unit
|
||||||
|
|
||||||
|
public interface A {
|
||||||
|
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 interface B : A {
|
||||||
|
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
@@ -25835,6 +25835,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/smartCasts/threeImplicitReceivers.kt");
|
runTest("compiler/testData/diagnostics/tests/smartCasts/threeImplicitReceivers.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("throwInTry.kt")
|
||||||
|
public void testThrowInTry() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/smartCasts/throwInTry.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("twoImplicitReceivers.kt")
|
@TestMetadata("twoImplicitReceivers.kt")
|
||||||
public void testTwoImplicitReceivers() throws Exception {
|
public void testTwoImplicitReceivers() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user