[K2] Prohibit smart casts for 'expect' properties
^KT-61340
This commit is contained in:
committed by
Space Team
parent
e4ea733482
commit
e3bab4a7da
+25
@@ -0,0 +1,25 @@
|
||||
// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
expect val foo: Any
|
||||
|
||||
expect class Bar() {
|
||||
val bus: Any
|
||||
}
|
||||
|
||||
fun common() {
|
||||
if (foo is String) <!SMARTCAST_IMPOSSIBLE!>foo<!>.length
|
||||
|
||||
val bar = Bar()
|
||||
if (bar.bus is String) <!SMARTCAST_IMPOSSIBLE!>bar.bus<!>.length
|
||||
}
|
||||
|
||||
// MODULE: m1-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
actual val foo: Any = 2
|
||||
|
||||
actual class Bar actual constructor() {
|
||||
actual val bus: Any
|
||||
get() = "bus"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
expect val foo: Any
|
||||
|
||||
expect class Bar() {
|
||||
val bus: Any
|
||||
}
|
||||
|
||||
fun common() {
|
||||
if (foo is String) foo.length
|
||||
|
||||
val bar = Bar()
|
||||
if (bar.bus is String) <!SMARTCAST_IMPOSSIBLE{JVM}!>bar.bus<!>.length
|
||||
}
|
||||
|
||||
// MODULE: m1-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
actual val foo: Any = 2
|
||||
|
||||
actual class Bar actual constructor() {
|
||||
actual val bus: Any
|
||||
get() = "bus"
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
expect val foo: Any
|
||||
|
||||
expect class Bar() {
|
||||
val bus: Any
|
||||
}
|
||||
|
||||
// MODULE: m1-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
actual val foo: Any = 2
|
||||
|
||||
actual class Bar actual constructor() {
|
||||
actual val bus: Any
|
||||
get() = "bus"
|
||||
}
|
||||
|
||||
fun platform() {
|
||||
if (foo is String) foo.length
|
||||
|
||||
val bar = Bar()
|
||||
if (bar.bus is String) <!SMARTCAST_IMPOSSIBLE!>bar.bus<!>.length
|
||||
}
|
||||
Reference in New Issue
Block a user