Files
kotlin-fork/compiler/testData/codegen/box/inlineClasses/kt38680b.kt
T
Dmitry Petrov 2f82c5b6af JVM: Fix default parameter values handling
When we generate call for 'foo', we make decision about invoking
a 'foo$default' too late, after the call arguments are generated.
If 'foo' was an override, and base class (interface) was generic,
'foo' in base class could have a different Kotlin and JVM
signature, so the arguments we generated could be generated wrong
(primitive or inline class values instead of boxes, see KT-38680).
Also, we always selected first base class in supertypes list,
which caused KT-15971.

Look into resolved call and see if we should actually call
'foo$default' instead of 'foo' when determining actual callable.

Overrides can't introduce default parameter values, and
override-equivalent inherited methods with default parameters
is an error in a child class. Thus, if we are calling a class
member function with a default parameters, there should be one
and only one overridden function that has default parameter values
and overrides nothing.
2020-05-20 07:19:29 +03:00

17 lines
319 B
Kotlin
Vendored

// !LANGUAGE: +InlineClasses
inline class IC(val s: String)
interface IFoo<T> {
fun foo(x: T, s: String = "K"): String
}
interface IFoo2<T> : IFoo<T> {
fun bar(x: T) = foo(x)
}
class FooImpl : IFoo2<IC> {
override fun foo(x: IC, s: String): String = x.s + s
}
fun box(): String = FooImpl().bar(IC("O"))