Files
kotlin-fork/compiler/testData/codegen/box/super/unqualifiedSuperWithLocalClass.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

30 lines
582 B
Kotlin
Vendored

interface Interface {
fun foo(x: Int): Int
}
fun withLocalClasses(param: Int): Interface {
open class LocalBase {
open val param: Int
get() = 100
}
interface LocalInterface : Interface {
override fun foo(x: Int): Int =
x + param
}
return object : LocalBase(), LocalInterface {
override fun foo(x: Int): Int =
x + super.param
}
}
fun box(): String {
val t = withLocalClasses(1)
val test1 = t.foo(10)
if (test1 != 110) return "Fail: t.foo(10)==$test1"
return "OK"
}