FIR: Implement FE 1.0 semantics for super unqualified calls

See original logic at org.jetbrains.kotlin.types.expressions.unqualifiedSuper.UnqualifiedSuperKt#resolveUnqualifiedSuperFromExpressionContext

^KT-39070 Fixed
^KT-39599 Related
This commit is contained in:
Denis Zharkov
2020-07-20 12:24:51 +03:00
parent dfc75f3447
commit cd896ae6c8
26 changed files with 285 additions and 82 deletions
@@ -0,0 +1,21 @@
interface A
open class B {
override fun equals(other: Any?): Boolean {
return super.equals(other)
}
override fun hashCode(): Int {
return super.hashCode()
}
}
class C : A, B() {
override fun equals(other: Any?): Boolean {
return super.equals(other)
}
override fun hashCode(): Int {
return super.hashCode()
}
}
@@ -0,0 +1,31 @@
FILE: superAny.kt
public abstract interface A : R|kotlin/Any| {
}
public open class B : R|kotlin/Any| {
public constructor(): R|B| {
super<R|kotlin/Any|>()
}
public open override fun equals(other: R|kotlin/Any?|): R|kotlin/Boolean| {
^equals this@R|/B|.super<R|kotlin/Any|>.R|kotlin/Any.equals|(R|<local>/other|)
}
public open override fun hashCode(): R|kotlin/Int| {
^hashCode this@R|/B|.super<R|kotlin/Any|>.R|kotlin/Any.hashCode|()
}
}
public final class C : R|A|, R|B| {
public constructor(): R|C| {
super<R|B|>()
}
public final override fun equals(other: R|kotlin/Any?|): R|kotlin/Boolean| {
^equals this@R|/C|.super<R|B|>.R|/B.equals|(R|<local>/other|)
}
public final override fun hashCode(): R|kotlin/Int| {
^hashCode this@R|/C|.super<R|B|>.R|/B.hashCode|()
}
}
@@ -15,7 +15,7 @@ class C : A, B() {
override fun foo() {
super.foo()
super.<!AMBIGUITY!>bar<!>() // should be ambiguity (NB: really we should have overridden bar in C)
super.<!UNRESOLVED_REFERENCE!>bar<!>() // should be ambiguity (NB: really we should have overridden bar in C)
super.baz() // Ok
baz() // Ok
@@ -27,9 +27,9 @@ FILE: incorrectSuperCall.kt
}
public final override fun foo(): R|kotlin/Unit| {
this@R|/C|.super<R|A|R|B|>.R|/B.foo|()
this@R|/C|.super<R|A|R|B|>.<Ambiguity: bar, [/A.bar, /B.bar]>#()
this@R|/C|.super<R|A|R|B|>.R|/B.baz|()
this@R|/C|.super<R|B|>.R|/B.foo|()
this@R|/C|.super<<ERROR TYPE REF: Ambiguous supertype>>.<Unresolved name: bar>#()
this@R|/C|.super<R|B|>.R|/B.baz|()
this@R|/C|.R|/A.baz|()
}