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
This commit is contained in:
Alexander Udalov
2015-05-28 21:17:39 +03:00
parent b474fa9278
commit 6e97f85863
3 changed files with 29 additions and 9 deletions
@@ -16,4 +16,8 @@ fun main() {
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)
}
@@ -16,4 +16,8 @@ fun main() {
checkSubtype<KMemberFunction0<A, Unit>>(x)
checkSubtype<KMemberFunction1<A, Int, Unit>>(y)
checkSubtype<KMemberFunction0<A, String>>(z)
checkSubtype<KMemberFunction<A, Unit>>(x)
checkSubtype<KMemberFunction<A, Unit>>(y)
checkSubtype<KMemberFunction<A, String>>(z)
}