Revert "FIR checkers: report SMARTCAST_IMPOSSIBLE"

This reverts commit 84334b08
This commit is contained in:
Dmitriy Novozhilov
2021-06-03 09:48:50 +03:00
parent 20d1a84002
commit 796f8e6bce
51 changed files with 297 additions and 308 deletions
@@ -0,0 +1,13 @@
public class X {
private val x : String? = null
public val y: CharSequence?
get() = x?.subSequence(0, 1)
public fun fn(): Int {
if (y != null)
// With non-default getter smartcast is not possible
return y<!UNSAFE_CALL!>.<!>length
else
return 0
}
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
public class X {
private val x : String? = null
public val y: CharSequence?
@@ -0,0 +1,11 @@
public open class A() {
public open val foo: Int? = 1
}
infix fun Int.bar(i: Int) = i
fun test() {
val p = A()
// For open value properties, smart casts should not work
if (p.foo is Int) p.foo <!UNSAFE_INFIX_CALL!>bar<!> 11
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
public open class A() {
public open val foo: Int? = 1
}
@@ -0,0 +1,35 @@
// MODULE: m1
// FILE: a.kt
package a
public class X {
public val x : String? = null
}
// MODULE: m2(m1)
// FILE: b.kt
package b
import a.X
public fun X.gav(): Int {
if (x != null)
// Smart cast is not possible if definition is in another module
return x<!UNSAFE_CALL!>.<!>length
else
return 0
}
// FILE: c.kt
package a
public fun X.gav(): Int {
if (x != null)
// Even if it's in the same package
return x<!UNSAFE_CALL!>.<!>length
else
return 0
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// MODULE: m1
// FILE: a.kt
@@ -0,0 +1,15 @@
public class X {
public var x : String? = null
private var y: String? = "abc"
public fun fn(): Int {
if (x != null)
// Smartcast is not possible for variable properties
return x<!UNSAFE_CALL!>.<!>length
else if (y != null)
// Even if they are private
return y<!UNSAFE_CALL!>.<!>length
else
return 0
}
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
public class X {
public var x : String? = null
private var y: String? = "abc"