Fix Kotlin default interface methods calls for inline classes

When mapping callable method signature for erased inline class methods,
use original function descriptor instead of super declaration
(otherwise it would map to a default interface method with mismatching
signature).

When generating delegates to Kotlin default interface methods, keep
track of the original Kotlin types for delegating method arguments and
interface method arguments.

'original' for value parameters of fake overrides points to the
overridden function value parameters instead of the value parameter of
the unsubstituted function. This causes inconsistent type mapping for
inline classes implementing generic interfaces with default methods.

 #KT-25295 Fixed Target versions 1.3.20
 #KT-26931 Fixed Target versions 1.3.20
This commit is contained in:
Dmitry Petrov
2018-09-20 12:40:01 +03:00
parent 8536ef5b43
commit 8d2b1950e6
14 changed files with 363 additions and 9 deletions
@@ -0,0 +1,27 @@
// !LANGUAGE: +InlineClasses
// IGNORE_BACKEND: JVM_IR
interface IFoo {
fun foo() = bar()
fun bar(): String
}
inline class Z(val x: Int) : IFoo {
override fun bar(): String = "OK"
}
inline class L(val x: Long) : IFoo {
override fun bar(): String = "OK"
}
inline class S(val x: String) : IFoo {
override fun bar(): String = "OK"
}
fun box(): String {
if (Z(42).foo() != "OK") throw AssertionError()
if (L(4L).foo() != "OK") throw AssertionError()
if (S("").foo() != "OK") throw AssertionError()
return "OK"
}