[FIR] Implement super resolve as a particular tower resolver case

This commit is contained in:
Mikhail Glukhikh
2020-01-29 12:41:45 +03:00
parent ee020ef290
commit 71b0840ef9
42 changed files with 211 additions and 71 deletions
@@ -2,6 +2,6 @@
enum class E : Cloneable {
A;
override fun clone(): Any {
return super.clone()
return super.<!AMBIGUITY!>clone<!>()
}
}
@@ -14,9 +14,9 @@ class C : T {
fun T.buzz() {}
fun T.buzz1() {}
super.foo() // OK
super.bar() // Error
super.<!UNRESOLVED_REFERENCE!>bar<!>() // Error
super.buzz() // OK, resolved to a member
super.buzz1() // Resolved to an extension
super.<!INAPPLICABLE_CANDIDATE!>buzz1<!>() // Resolved to an extension
super.<!INAPPLICABLE_CANDIDATE!>buzz1<!>("") // Resolved to a member
}
}
@@ -12,7 +12,7 @@ class A<E>() : C(), T {
fun test() {
super
super<T>
super.<!UNRESOLVED_REFERENCE!>foo<!>()
super.foo()
super<T>.foo()
super<C>.bar()
super<T>@A.foo()
@@ -4,6 +4,6 @@ fun Any.extension(arg: Any?) {}
class A1 {
fun test() {
super.extension(null) // Call to an extension function
super.<!UNRESOLVED_REFERENCE!>extension<!>(null) // Call to an extension function
}
}
@@ -11,28 +11,28 @@ interface GenericBaseInterface<T> {
class GenericDerivedClass<T> : GenericBaseClass<T>(), GenericBaseInterface<T> {
override fun foo(x: T): T = super.foo(x)
override fun bar(x: T): T = super.<!UNRESOLVED_REFERENCE!>bar<!>(x)
override fun bar(x: T): T = super.bar(x)
override fun ambiguous(x: T): T =
super.ambiguous(x)
super.<!AMBIGUITY!>ambiguous<!>(x)
}
class SpecializedDerivedClass : GenericBaseClass<Int>(), GenericBaseInterface<String> {
override fun foo(x: Int): Int = super.foo(x)
override fun bar(x: String): String = super.<!UNRESOLVED_REFERENCE!>bar<!>(x)
override fun bar(x: String): String = super.bar(x)
override fun ambiguous(x: String): String =
super.<!INAPPLICABLE_CANDIDATE!>ambiguous<!>(x)
super.ambiguous(x)
override fun ambiguous(x: Int): Int =
super.ambiguous(x)
}
class MixedDerivedClass<T> : GenericBaseClass<Int>(), GenericBaseInterface<T> {
override fun foo(x: Int): Int = super.foo(x)
override fun bar(x: T): T = super.<!UNRESOLVED_REFERENCE!>bar<!>(x)
override fun bar(x: T): T = super.bar(x)
override fun ambiguous(x: Int): Int =
super.ambiguous(x)
override fun ambiguous(x: T): T =
super.<!INAPPLICABLE_CANDIDATE!>ambiguous<!>(x)
super.ambiguous(x)
}
@@ -45,13 +45,13 @@ class Derived : Base(), Interface {
super.prop
fun getAmbiguousSuperProp(): Int =
super.ambiguousProp
super.<!AMBIGUITY!>ambiguousProp<!>
fun callsFunFromSuperInterface() {
super.<!UNRESOLVED_REFERENCE!>bar<!>()
super.bar()
}
fun callsAmbiguousSuperFun() {
super.ambiguous()
super.<!AMBIGUITY!>ambiguous<!>()
}
}
@@ -22,18 +22,18 @@ interface I {
class B : A(), I {
override val x: Int = 12345
override val y: Int = super.y
override val y: Int = super.<!AMBIGUITY!>y<!>
override fun foo(): Int {
super.foo()
return super.<!UNRESOLVED_REFERENCE!>x<!>
return super.x
}
override fun bar() {
super.bar()
super.<!AMBIGUITY!>bar<!>()
}
override fun qux() {
super.qux()
super.<!AMBIGUITY!>qux<!>()
}
}
@@ -43,8 +43,8 @@ class DeepDerived : DeepBase(), DeepInterface {
super.deeperBaseProp
fun callsSuperInterfaceFuns() {
super.<!UNRESOLVED_REFERENCE!>deeperInterfaceFun<!>()
super.<!UNRESOLVED_REFERENCE!>deepInterfaceFun<!>()
super.deeperInterfaceFun()
super.deepInterfaceFun()
super<DeepInterface>.deeperInterfaceFun()
super<DeepInterface>.deepInterfaceFun()
}
@@ -8,15 +8,15 @@ interface GenericBaseInterface<T> {
class GenericDerivedClass<T> : GenericBaseClass<T>(), GenericBaseInterface<T> {
override fun foo(x: T): T = super.foo(x)
override fun bar(x: T): T = super.<!UNRESOLVED_REFERENCE!>bar<!>(x)
override fun bar(x: T): T = super.bar(x)
}
class SpecializedDerivedClass : GenericBaseClass<Int>(), GenericBaseInterface<String> {
override fun foo(x: Int): Int = super.foo(x)
override fun bar(x: String): String = super.<!UNRESOLVED_REFERENCE!>bar<!>(x)
override fun bar(x: String): String = super.bar(x)
}
class MixedDerivedClass<T> : GenericBaseClass<Int>(), GenericBaseInterface<T> {
override fun foo(x: Int): Int = super.foo(x)
override fun bar(x: T): T = super.<!UNRESOLVED_REFERENCE!>bar<!>(x)
override fun bar(x: T): T = super.bar(x)
}
@@ -16,7 +16,7 @@ class C : A(), B {
}
override fun bar() {
super@C.<!UNRESOLVED_REFERENCE!>bar<!>()
super@C.bar()
}
inner class D : A(), Q {
@@ -26,8 +26,8 @@ class C : A(), B {
}
override fun qux() {
super@C.<!UNRESOLVED_REFERENCE!>qux<!>()
super@D.<!UNRESOLVED_REFERENCE!>qux<!>()
super@C.qux()
super@D.qux()
}
}
}
@@ -20,9 +20,9 @@ interface AnotherInterface {
interface DerivedInterface: Interface, AnotherInterface {
override fun foo() { super.foo() }
override fun ambiguous() {
super.ambiguous()
super.<!AMBIGUITY!>ambiguous<!>()
}
override val ambiguousProp: Int
get() = super.ambiguousProp
get() = super.<!AMBIGUITY!>ambiguousProp<!>
}
@@ -41,13 +41,13 @@ class ClassDerivedFromUnresolved : Base(), Interface, Unresolved {
super.prop
fun getAmbiguousSuperProp(): Int =
super.ambiguousProp
super.<!AMBIGUITY!>ambiguousProp<!>
fun callsFunFromSuperInterface() {
super.<!UNRESOLVED_REFERENCE!>bar<!>()
super.bar()
}
fun callsAmbiguousSuperFun() {
super.ambiguous()
super.<!AMBIGUITY!>ambiguous<!>()
}
}
@@ -15,7 +15,7 @@ class Test1 : C(), A {
// Abstract 'foo' defined in 'C' wins against non-abstract 'foo' defined in 'A',
// because 'C' is a subclass of 'A' (and 'C::foo' overrides 'A::foo'),
// even though 'A' is explicitly listed in supertypes list for 'D'.
super.foo()
super.<!AMBIGUITY!>foo<!>()
}
}
@@ -23,7 +23,7 @@ class Test2 : C(), A, Unrelated {
override fun foo() {
// This is ok, because there's a non-abstract 'foo' in 'Unrelated',
// which is not overridden by abstract 'foo' in 'C'.
super.foo()
super.<!AMBIGUITY!>foo<!>()
super<Unrelated>.foo()
}
}