53c5230520
Otherwise it leads to the following problem in the newly added test.
Suppose that we have a fake override `remove(Int)` inherited from
LinkedList _without_ EnhancedNullability on its parameter type. By
normal Kotlin rules, this method should override the method from
KotlinInterface. However, on JVM we have another overridability check in
IrJavaIncompatibilityRulesOverridabilityCondition which ensures that
"JVM primitivity" of parameter types is the same for the base and the
overridden method.
So the fake override `remove(Int)` from LinkedList is determined to be
override-incompatible with `remove(Int)` from KotlinInterface. But when
we try to create symbols for all fake overrides in the class, we get a
clash because there are two fake overrides with exactly the same
IdSignature, neither of which overrides the other.
If we keep the EnhancedNullability annotation on the parameter, it
starts working because the logic of computing signature in
JvmIrMangler.JvmIrManglerComputer.mangleTypePlatformSpecific adds an
"{EnhancedNullability}" mark to the IdSignature of a fake override from
LinkedList.
#KT-65499 Fixed
25 lines
372 B
Kotlin
Vendored
25 lines
372 B
Kotlin
Vendored
// TARGET_BACKEND: JVM
|
|
// FULL_JDK
|
|
|
|
import java.util.LinkedList
|
|
|
|
interface KotlinInterface {
|
|
fun remove(i: Int): Boolean
|
|
}
|
|
|
|
var result = "Fail"
|
|
|
|
abstract class C : LinkedList<Int>(), KotlinInterface
|
|
|
|
class D : C() {
|
|
override fun remove(i: Int): Boolean {
|
|
result = "OK"
|
|
return true
|
|
}
|
|
}
|
|
|
|
fun box(): String {
|
|
D().remove(0)
|
|
return result
|
|
}
|