Files
kotlin-fork/compiler/testData/diagnostics/tests/callableReference/function/extensionFromTopLevel.kt
T
Alexander Udalov 6e97f85863 Fix type argument substitution bug in KFunction construction
For example,

KMemberFunction2<T, P1, P2, R> : KMemberFunction<T, R>

So for this inheritance the heuristic that was present ("take the last K type
parameters of the subclass, and substitute for K parameters of the superclass")
was wrong. The new heuristic for this case is: take type parameters with the
same names.

Also don't store "parameters" in a lazy value, since it's easy to compute and
it's computed practically every time anyway
2015-06-04 23:08:21 +03:00

24 lines
509 B
Kotlin
Vendored

// !CHECK_TYPE
import kotlin.reflect.*
class A
fun A.foo() {}
fun A.bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
fun A.baz() = "OK"
fun main() {
val x = A::foo
val y = A::bar
val z = A::baz
checkSubtype<KExtensionFunction0<A, Unit>>(x)
checkSubtype<KExtensionFunction1<A, Int, Unit>>(y)
checkSubtype<KExtensionFunction0<A, String>>(z)
checkSubtype<KExtensionFunction<A, Unit>>(x)
checkSubtype<KExtensionFunction<A, Unit>>(y)
checkSubtype<KExtensionFunction<A, String>>(z)
}