[FIR] Don't smartcast variables to invisible types

#KT-44802 Fixed
This commit is contained in:
Dmitriy Novozhilov
2021-02-18 11:19:08 +03:00
parent 026efca49f
commit 1c0d862e40
24 changed files with 521 additions and 17 deletions
+46
View File
@@ -0,0 +1,46 @@
// TARGET_BACKEND: JVM
// ISSUE: KT-44802
// FILE: foo/Base.java
package foo;
public interface Base {
String foo();
}
// FILE: foo/PackagePrivateInterface.java
package foo;
interface PackagePrivateInterface extends Base {}
// FILE: foo/A.java
package foo;
public class A implements PackagePrivateInterface {
public String foo() { return "OK"; }
}
// FILE: foo/B.java
package foo;
public class B implements PackagePrivateInterface {
public String foo() { return "B"; }
}
// FILE: foo/C.java
package foo;
// FILE: main.kt
package bar
import foo.Base
import foo.A
import foo.B
fun testSmartcast(x: Base): String {
if (x !is A && x !is B) return "fail"
return x.foo()
}
fun box() = testSmartcast(A())