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
@@ -1,3 +1,4 @@
// !LANGUAGE: -ProhibitSmartcastsOnPropertyFromAlienBaseClass
// MODULE: m1
// FILE: A.kt
@@ -1,3 +1,4 @@
// !LANGUAGE: -ProhibitSmartcastsOnPropertyFromAlienBaseClass
// MODULE: m1
// FILE: A.kt
@@ -10,7 +11,7 @@ open class Generic<T>(val y: T)
class Derived : Base("123") {
fun foo() {
if (x is String) {
<!DEBUG_INFO_SMARTCAST!>x<!>.length // impossible since `x` is in another module. FE1.0 allows this due to KT-47225
<!DEBUG_INFO_SMARTCAST, DEPRECATED_SMARTCAST!>x<!>.length // impossible since `x` is in another module. FE1.0 allows this due to KT-47225
}
}
}
@@ -19,7 +20,7 @@ class MyGeneric : Generic<Number>(42) {
private fun baz(arg: Int) {}
fun bar() {
if (y is Int) {
baz(<!DEBUG_INFO_SMARTCAST!>y<!>) // impossible since `y` is in another module. FE1.0 allows this due to KT-47225
baz(<!DEBUG_INFO_SMARTCAST, DEPRECATED_SMARTCAST!>y<!>) // impossible since `y` is in another module. FE1.0 allows this due to KT-47225
}
}
}
@@ -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
}
}
}
@@ -0,0 +1,40 @@
// -- Module: <m1> --
package
public open class Base {
public constructor Base(/*0*/ x: kotlin.Any)
public final val x: kotlin.Any
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public open class Generic</*0*/ T> {
public constructor Generic</*0*/ T>(/*0*/ y: T)
public final val y: T
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
// -- Module: <m2> --
package
public final class Derived : Base {
public constructor Derived()
public final override /*1*/ /*fake_override*/ val x: kotlin.Any
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class MyGeneric : Generic<kotlin.Number> {
public constructor MyGeneric()
public final override /*1*/ /*fake_override*/ val y: kotlin.Number
public final fun bar(): kotlin.Unit
private final fun baz(/*0*/ arg: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}