2f82c5b6af
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.
19 lines
311 B
Kotlin
Vendored
19 lines
311 B
Kotlin
Vendored
// IGNORE_BACKEND_FIR: JVM_IR
|
|
interface Q {
|
|
fun foo(a: Double) = 0.0
|
|
}
|
|
|
|
interface Z {
|
|
fun foo(a: Double = 1.0): Double
|
|
}
|
|
|
|
class R : Q, Z {
|
|
override fun foo(a: Double) = a
|
|
}
|
|
|
|
fun box(): String {
|
|
if (R().foo() != 1.0) return "fail 1"
|
|
if (R().foo(2.0) != 2.0) return "fail 2"
|
|
return "OK"
|
|
}
|