Files
kotlin-fork/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/unqualifiedSuper.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

58 lines
1.0 KiB
Kotlin
Vendored

// Base Interface
// \ /
// \/
// Derived
//
open class Base() {
open fun foo() {}
open fun ambiguous() {}
open val prop: Int
get() = 1234
open val ambiguousProp: Int
get() = 111
}
interface Interface {
fun bar() {}
fun ambiguous() {}
val ambiguousProp: Int
get() = 222
}
class Derived : Base(), Interface {
override fun foo() {}
override fun bar() {}
override fun ambiguous() {}
override val ambiguousProp: Int
get() = 333
override val prop: Int
get() = 4321
fun callsFunFromSuperClass() {
super.foo()
}
fun getSuperProp(): Int =
super.prop
fun getAmbiguousSuperProp(): Int =
<!AMBIGUOUS_SUPER!>super<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>ambiguousProp<!>
fun callsFunFromSuperInterface() {
super.bar()
}
fun callsAmbiguousSuperFun() {
<!AMBIGUOUS_SUPER!>super<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>ambiguous<!>()
}
}