[FIR-TEST] Add test with missing smartcast
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
interface A {
|
||||
fun foo()
|
||||
}
|
||||
|
||||
fun takeA(a: A): Boolean = true
|
||||
|
||||
fun test(a: Any) {
|
||||
if (takeA(a as? A ?: return)) {
|
||||
a.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
FILE: noSmartcast.kt
|
||||
public abstract interface A : R|kotlin/Any| {
|
||||
public abstract fun foo(): R|kotlin/Unit|
|
||||
|
||||
}
|
||||
public final fun takeA(a: R|A|): R|kotlin/Boolean| {
|
||||
^takeA Boolean(true)
|
||||
}
|
||||
public final fun test(a: R|kotlin/Any|): R|kotlin/Unit| {
|
||||
when () {
|
||||
R|/takeA|(when (lval <elvis>: R|A?| = (R|<local>/a| as R|A?|)) {
|
||||
==($subj$, Null(null)) -> {
|
||||
^test Unit
|
||||
}
|
||||
else -> {
|
||||
R|<local>/<elvis>|
|
||||
}
|
||||
}
|
||||
) -> {
|
||||
R|<local>/a|.R|/A.foo|()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -913,6 +913,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
|
||||
runTest("compiler/fir/resolve/testData/resolve/problems/nestedClassContructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noSmartcast.kt")
|
||||
public void testNoSmartcast() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/problems/noSmartcast.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("propertyFromJavaPlusAssign.kt")
|
||||
public void testPropertyFromJavaPlusAssign() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/problems/propertyFromJavaPlusAssign.kt");
|
||||
|
||||
Reference in New Issue
Block a user