Files
kotlin-fork/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/unqualifiedSuperWithAbstractMembers.kt
T
dnpetrov 046189087a KT-5963 Call to super shouldn't require type specification if there is no conflict
Implemented unqualified 'super' type resolution (in BasicExpressionTypingVisitor).

No overload resolution of any kind is involved.
Corresponding supertype is determined by the expected member name only:
- 'super.foo(...)' - function or property (of possibly callable type) 'foo'
- 'super.x' - property 'x'
Supertype should provide a non-abstract implementation of such member.
As a fall-back solution for diagnostics purposes, consider supertypes with abstract implementation of such member.

Diagnostics:
- AMBIGUOUS_SUPER on 'super', if multiple possible supertypes are available;
- ABSTRACT_SUPER_CALL on selector expression, if the only available implementation is abstract.

#KT-5963 Fixed
2015-06-18 14:16:34 +03:00

40 lines
850 B
Kotlin
Vendored

// fun foo: abstract in A, unresolved in I
// fun bar: implemented in A, abstract in I
// fun qux: abstract in A, abstract in I
// val x: unresolved in A, abstract in I
// val y: abstract in A, implemented in I
abstract class A {
abstract fun foo(): Int
open fun bar() {}
abstract fun qux()
abstract val y: Int
}
interface I {
fun bar()
fun qux()
val x: Int
val y: Int get() = 111
}
class B : A(), I {
override val x: Int = 12345
override val y: Int = super.y
override fun foo(): Int {
super.<!ABSTRACT_SUPER_CALL!>foo<!>()
return super.<!ABSTRACT_SUPER_CALL!>x<!>
}
override fun bar() {
super.bar()
}
override fun qux() {
<!AMBIGUOUS_SUPER!>super<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>qux<!>()
}
}