FIR DFA: add tests about smartcasts in/after try-catch-finally

This commit is contained in:
Jinseong Jeon
2020-10-12 22:45:31 -07:00
committed by Dmitriy Novozhilov
parent 2c8c47399a
commit 146036010c
9 changed files with 137 additions and 0 deletions
@@ -21915,6 +21915,16 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/smartCasts/castchecks/basicOn.kt");
}
@TestMetadata("castInTryWithCatch.kt")
public void testCastInTryWithCatch() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/castchecks/castInTryWithCatch.kt");
}
@TestMetadata("castInTryWithoutCatch.kt")
public void testCastInTryWithoutCatch() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/castchecks/castInTryWithoutCatch.kt");
}
@TestMetadata("impossible.kt")
public void testImpossible() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/castchecks/impossible.kt");
@@ -0,0 +1,32 @@
fun castInTry(s: Any) {
try {
s as String // Potential cast exception
} catch (e: Exception) {
s.length // shouldn't be resolved
} finally {
s.length // shouldn't be resolved
}
s.length // shouldn't be resolved
}
fun castInTryAndCatch(s: Any) {
try {
s as String // Potential cast exception
} catch (e: Exception) {
s as String // Potential cast exception
} finally {
s.length // shouldn't be resolved
}
s.length // should be smartcast
}
fun castAtAll(s: Any) {
try {
s as String // Potential cast exception
} catch (e: Exception) {
s as String // Potential cast exception
} finally {
s as String // Potential cast exception
}
s.length
}
@@ -0,0 +1,32 @@
fun castInTry(s: Any) {
try {
s as String // Potential cast exception
} catch (e: Exception) {
s.<!UNRESOLVED_REFERENCE!>length<!> // shouldn't be resolved
} finally {
s.<!UNRESOLVED_REFERENCE!>length<!> // shouldn't be resolved
}
s.<!UNRESOLVED_REFERENCE!>length<!> // shouldn't be resolved
}
fun castInTryAndCatch(s: Any) {
try {
s as String // Potential cast exception
} catch (e: Exception) {
s as String // Potential cast exception
} finally {
s.<!UNRESOLVED_REFERENCE!>length<!> // shouldn't be resolved
}
s.<!UNRESOLVED_REFERENCE!>length<!> // should be smartcast
}
fun castAtAll(s: Any) {
try {
s as String // Potential cast exception
} catch (e: Exception) {
s as String // Potential cast exception
} finally {
s as String // Potential cast exception
}
<!DEBUG_INFO_SMARTCAST!>s<!>.length
}
@@ -0,0 +1,5 @@
package
public fun castAtAll(/*0*/ s: kotlin.Any): kotlin.Unit
public fun castInTry(/*0*/ s: kotlin.Any): kotlin.Unit
public fun castInTryAndCatch(/*0*/ s: kotlin.Any): kotlin.Unit
@@ -0,0 +1,17 @@
fun castInTry(s: Any) {
try {
s as String // Potential cast exception
} finally {
s.length // Shouldn't be resolved
}
s.length // Shouldn't be resolved
}
fun castInTryAndFinally(s: Any) {
try {
s as String // Potential cast exception
} finally {
s as String // Potential cast exception
}
s.length // Should be smartcast
}
@@ -0,0 +1,17 @@
fun castInTry(s: Any) {
try {
s as String // Potential cast exception
} finally {
s.<!UNRESOLVED_REFERENCE!>length<!> // Shouldn't be resolved
}
s.<!UNRESOLVED_REFERENCE!>length<!> // Shouldn't be resolved
}
fun castInTryAndFinally(s: Any) {
try {
s as String // Potential cast exception
} finally {
s as String // Potential cast exception
}
<!DEBUG_INFO_SMARTCAST!>s<!>.length // Should be smartcast
}
@@ -0,0 +1,4 @@
package
public fun castInTry(/*0*/ s: kotlin.Any): kotlin.Unit
public fun castInTryAndFinally(/*0*/ s: kotlin.Any): kotlin.Unit
@@ -21992,6 +21992,16 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTestWithFirVali
runTest("compiler/testData/diagnostics/tests/smartCasts/castchecks/basicOn.kt");
}
@TestMetadata("castInTryWithCatch.kt")
public void testCastInTryWithCatch() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/castchecks/castInTryWithCatch.kt");
}
@TestMetadata("castInTryWithoutCatch.kt")
public void testCastInTryWithoutCatch() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/castchecks/castInTryWithoutCatch.kt");
}
@TestMetadata("impossible.kt")
public void testImpossible() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/castchecks/impossible.kt");
@@ -21917,6 +21917,16 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/diagnostics/tests/smartCasts/castchecks/basicOn.kt");
}
@TestMetadata("castInTryWithCatch.kt")
public void testCastInTryWithCatch() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/castchecks/castInTryWithCatch.kt");
}
@TestMetadata("castInTryWithoutCatch.kt")
public void testCastInTryWithoutCatch() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/castchecks/castInTryWithoutCatch.kt");
}
@TestMetadata("impossible.kt")
public void testImpossible() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/castchecks/impossible.kt");