[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.
This commit is contained in:
committed by
Space Team
parent
5186ba80e2
commit
ad2689ecbf
+17
@@ -27,4 +27,21 @@ class Derived : Base() {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+17
@@ -27,4 +27,21 @@ class Derived : Base() {
|
||||
<!INVISIBLE_SETTER!>x.y<!> = x.y + 1
|
||||
}
|
||||
}
|
||||
|
||||
protected fun baz2(x: Base?) {
|
||||
x<!UNSAFE_CALL!>.<!><!INVISIBLE_MEMBER!>foo<!>()
|
||||
x<!UNSAFE_CALL!>.<!><!INVISIBLE_MEMBER!>bar<!>()
|
||||
|
||||
x<!UNSAFE_CALL!>.<!><!INVISIBLE_MEMBER!>x<!> = x<!UNSAFE_CALL!>.<!><!INVISIBLE_MEMBER!>x<!> + 1
|
||||
<!INVISIBLE_SETTER!>x<!UNSAFE_CALL!>.<!>y<!> = x<!UNSAFE_CALL!>.<!>y + 1
|
||||
|
||||
if (x is Derived) {
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.foo()
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.bar()
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.baz(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.x = <!DEBUG_INFO_SMARTCAST!>x<!>.x + 1
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.y = <!DEBUG_INFO_SMARTCAST!>x<!>.y + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
package
|
||||
|
||||
public open class Base {
|
||||
public constructor Base()
|
||||
protected open var x: kotlin.Int
|
||||
public open var y: kotlin.Int
|
||||
protected open fun bar(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
protected open 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 Derived : Base {
|
||||
public constructor Derived()
|
||||
protected open override /*1*/ /*fake_override*/ var x: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ var y: kotlin.Int
|
||||
protected open override /*1*/ fun bar(): kotlin.Unit
|
||||
protected final fun baz(/*0*/ x: Base): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
protected open override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user