Restore correct overloads ambiguity accidentally removed in 1.3.60

This problem is only relevant when isTypeRefinementEnabled == true (HMPP projects)

Ambiguity accidentally was removed after 471134d
There, for areCallableDescriptorsEquivalent we stopped assuming
as impossible a situation of having identity-different descriptors
in the same containing declaraton that still might be considered equal

So, before 471134d we were comparing
"fun foo(x: String)" with "[substituted] fun foo(x: String)"
and areCallableDescriptorsEquivalent returned false for such case.
Thus, both overrides were left in the resulting set.

After 471134d, those two descriptors
becamed considered as equal thus having a possibility to remove any of them.

The problem is that "areCallableDescriptorsEquivalent" has kind of
unclear contract. Effectively it checks whether two descriptors match
to the same declaration.

But some of the usages expect that it also makes sure that descriptors
have the same substitution (see org.jetbrains.kotlin.resolve.calls.smartcasts.IdentifierInfo.Variable#equals)

So, the straight solution is using original descriptors for the cases
where we need to make sure that descriptors relates to actually different
declarations

^KT-34027 Fixed
This commit is contained in:
Denis Zharkov
2019-09-30 17:18:43 +03:00
parent 67410f7a57
commit f91db5f0b8
10 changed files with 77 additions and 2 deletions
@@ -0,0 +1,6 @@
// KT-34027
expect interface A<T> {
fun foo(x: T)
}
fun bar(): A<String> = null!!
@@ -0,0 +1,5 @@
MODULE common { platform=[JVM, JS, Native] }
MODULE js { platform=[JS] }
js -> common { kind=DEPENDS_ON }
@@ -0,0 +1,8 @@
actual interface A<T> {
actual fun foo(x: T)
fun foo(x: String)
}
fun main() {
bar().<!OVERLOAD_RESOLUTION_AMBIGUITY(" public abstract actual fun foo(x: String): Unit defined in A public abstract fun foo(x: String): Unit defined in A")!>foo<!>("")
}