[FIR-TEST] Add test with missing smartcast

This commit is contained in:
Dmitriy Novozhilov
2019-11-28 14:24:42 +03:00
parent dcd1c2647e
commit 61c17d9110
3 changed files with 40 additions and 0 deletions
@@ -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|()
}
}
}
@@ -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");