Deprecate smart cast on alien derived property #KT-48101 Fixed

This commit is contained in:
Mikhail Glukhikh
2021-08-23 17:39:35 +03:00
parent 3f8734f694
commit 12726bde15
12 changed files with 138 additions and 7 deletions
@@ -0,0 +1,27 @@
// FIR_IDENTICAL
// !LANGUAGE: +ProhibitSmartcastsOnPropertyFromAlienBaseClass
// MODULE: m1
// FILE: A.kt
open class Base(val x: Any)
open class Generic<T>(val y: T)
// MODULE: m2(m1)
// FILE: B.kt
class Derived : Base("123") {
fun foo() {
if (x is String) {
<!SMARTCAST_IMPOSSIBLE!>x<!>.length // impossible since `x` is in another module. FE1.0 allows this due to KT-47225
}
}
}
class MyGeneric : Generic<Number>(42) {
private fun baz(arg: Int) {}
fun bar() {
if (y is Int) {
baz(<!SMARTCAST_IMPOSSIBLE!>y<!>) // impossible since `y` is in another module. FE1.0 allows this due to KT-47225
}
}
}