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
@@ -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