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
This commit is contained in:
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
open class GenericBaseClass<T> {
|
||||
open fun foo(x: T): T = x
|
||||
open fun ambiguous(x: T): T = x
|
||||
}
|
||||
|
||||
interface GenericBaseInterface<T> {
|
||||
fun bar(x: T): T = x
|
||||
fun ambiguous(x: T): T = x
|
||||
}
|
||||
|
||||
class GenericDerivedClass<T> : GenericBaseClass<T>(), GenericBaseInterface<T> {
|
||||
override fun foo(x: T): T = super.foo(x)
|
||||
override fun bar(x: T): T = super.bar(x)
|
||||
|
||||
override fun ambiguous(x: T): T =
|
||||
<!AMBIGUOUS_SUPER!>super<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>ambiguous<!>(x)
|
||||
}
|
||||
|
||||
class <!CONFLICTING_JVM_DECLARATIONS!>SpecializedDerivedClass<!> : GenericBaseClass<Int>(), GenericBaseInterface<String> {
|
||||
override fun foo(x: Int): Int = super.foo(x)
|
||||
override fun bar(x: String): String = super.bar(x)
|
||||
|
||||
override fun ambiguous(x: String): String =
|
||||
<!AMBIGUOUS_SUPER!>super<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>ambiguous<!>(x)
|
||||
override fun ambiguous(x: Int): Int =
|
||||
<!AMBIGUOUS_SUPER!>super<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>ambiguous<!>(x)
|
||||
}
|
||||
|
||||
class <!CONFLICTING_JVM_DECLARATIONS!>MixedDerivedClass<!><T> : GenericBaseClass<Int>(), GenericBaseInterface<T> {
|
||||
override fun foo(x: Int): Int = super.foo(x)
|
||||
override fun bar(x: T): T = super.bar(x)
|
||||
|
||||
override fun ambiguous(x: Int): Int =
|
||||
<!AMBIGUOUS_SUPER!>super<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>ambiguous<!>(x)
|
||||
<!CONFLICTING_JVM_DECLARATIONS!>override fun ambiguous(x: T): T<!> =
|
||||
<!AMBIGUOUS_SUPER!>super<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>ambiguous<!>(x)
|
||||
}
|
||||
Reference in New Issue
Block a user