Files
Kirill Rakhman ad2689ecbf [FIR] Prefer the non-smartcasted receiver in resolution if it's visible
Previously, we would ignore the candidate with the non-smartcasted
receiver if they have the same symbol.
Now we prefer them when they're visible or when the smart cast changes
the nullability.
2023-12-21 13:29:01 +00:00

48 lines
1.1 KiB
Kotlin
Vendored

open class Base {
open protected fun foo() {}
open protected fun bar() {}
open protected var x: Int = 1
open var y: Int = 1
protected set
}
class Derived : Base() {
override fun bar() { }
protected fun baz(x: Base) {
x.<!INVISIBLE_REFERENCE!>foo<!>()
x.<!INVISIBLE_REFERENCE!>bar<!>()
x.<!INVISIBLE_REFERENCE!>x<!> = x.<!INVISIBLE_REFERENCE!>x<!> + 1
x.<!INVISIBLE_SETTER!>y<!> = x.y + 1
if (x is Derived) {
x.foo()
x.bar()
x.baz(x)
x.x = x.x + 1
// TODO: Should be smart cast
x.y = x.y + 1
}
}
protected fun baz2(x: Base?) {
x.<!INVISIBLE_REFERENCE!>foo<!>()
x.<!INVISIBLE_REFERENCE!>bar<!>()
x.<!INVISIBLE_REFERENCE!>x<!> = x.<!INVISIBLE_REFERENCE!>x<!> + 1
x.<!INVISIBLE_SETTER!>y<!> = x<!UNSAFE_CALL!>.<!>y + 1
if (x is Derived) {
x.foo()
x.bar()
x.baz(x)
x.x = x.x + 1
x.y = x.y + 1
}
}
}