K2: Avoid false-positive overload resolution ambiguity with smart casts
The idea is that when we have successful candidates both from smart cast and original type, we should discriminate in the favor of former ones. While this problem (see kt55722.kt) existed before this branch is merged, initially it was recognized on FP Ultimate when we stopped assuming captured types from the same projections as equal (see kt55722Initial.kt). ^KT-55722 Fixed ^KT-55024 Fixed ^KT-56283 Related ^KT-56310 Related
This commit is contained in:
committed by
Space Team
parent
7b6c6fceb6
commit
b6b132a9a3
+63
@@ -0,0 +1,63 @@
|
||||
FILE: moreSpecificProtectedSimple.fir.kt
|
||||
public abstract interface Base : R|kotlin/Any| {
|
||||
}
|
||||
public abstract interface Derived : R|Base| {
|
||||
}
|
||||
public abstract interface M1 : R|kotlin/Any| {
|
||||
public abstract val success: R|kotlin/Boolean|
|
||||
public get(): R|kotlin/Boolean|
|
||||
|
||||
}
|
||||
public abstract interface M1Sub : R|M1| {
|
||||
}
|
||||
public open class A : R|kotlin/Any| {
|
||||
public constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
protected open fun baz(a: R|Derived|): R|M1| {
|
||||
^baz R|kotlin/TODO|()
|
||||
}
|
||||
|
||||
protected open fun foo(a: R|Derived|): R|M1| {
|
||||
^foo R|kotlin/TODO|()
|
||||
}
|
||||
|
||||
public final fun f(a: R|A|, b: R|B|, d: R|Derived|): R|kotlin/Unit| {
|
||||
R|<local>/a|.R|/A.baz|(R|<local>/d|).R|/M1.success|
|
||||
R|<local>/a|.R|/A.foo|(R|<local>/d|).R|/M1.success|
|
||||
R|<local>/b|.R|/B.baz|(R|<local>/d|).R|kotlin/String.length|
|
||||
R|<local>/b|.R|/B.foo|(R|<local>/d|).R|kotlin/String.length|
|
||||
when (R|<local>/a|) {
|
||||
($subj$ is R|B|) -> {
|
||||
R|<local>/a|.R|/A.baz|(R|<local>/d|).<Unresolved name: length>#
|
||||
R|<local>/a|.R|/A.baz|(R|<local>/d|).R|/M1.success|
|
||||
R|<local>/a|.R|/A.foo|(R|<local>/d|).R|/M1.success|
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public final class B : R|A| {
|
||||
public constructor(): R|B| {
|
||||
super<R|A|>()
|
||||
}
|
||||
|
||||
protected open override fun baz(a: R|Derived|): R|M1Sub| {
|
||||
^baz R|kotlin/TODO|()
|
||||
}
|
||||
|
||||
public final fun baz(a: R|Base|): R|kotlin/String| {
|
||||
^baz R|kotlin/TODO|()
|
||||
}
|
||||
|
||||
protected open override fun foo(a: R|Derived|): R|M1| {
|
||||
^foo R|kotlin/TODO|()
|
||||
}
|
||||
|
||||
public final fun foo(a: R|Base|): R|kotlin/String| {
|
||||
^foo R|kotlin/TODO|()
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user