IR: copy EnhancedNullability in CopyIrTreeWithSymbolsForFakeOverrides
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
This commit is contained in:
committed by
Space Team
parent
f05c972efb
commit
53c5230520
@@ -0,0 +1,24 @@
|
||||
// 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
|
||||
}
|
||||
Reference in New Issue
Block a user