K2/Java: fix processing of built-in with value parameters to be erased in Java
In this commit we started to create and process a hidden copy for a built-in functions, which value parameters are erased in Java, in case we have an accidental Java override which value parameters are not erased. In this situation attempt to override such a Java override in Kotlin again will lead to inaccessible functions (see changes in containsAndOverload.fir.kt) #KT-64846 In Progress
This commit is contained in:
committed by
Space Team
parent
30ad532ff9
commit
ac729e28da
+23
-3
@@ -493,13 +493,13 @@ class JavaClassUseSiteMemberScope(
|
||||
return false
|
||||
}
|
||||
|
||||
val hasAccidentalOverrideWithDeclaredFunction = explicitlyDeclaredFunctionsWithNaturalName.any {
|
||||
val accidentalOverrideWithDeclaredFunction = explicitlyDeclaredFunctionsWithNaturalName.find {
|
||||
overrideChecker.isOverriddenFunction(
|
||||
renamedDeclaredFunction,
|
||||
it
|
||||
)
|
||||
}
|
||||
if (!hasAccidentalOverrideWithDeclaredFunction) {
|
||||
if (accidentalOverrideWithDeclaredFunction == null) {
|
||||
destination += renamedDeclaredFunction
|
||||
directOverriddenFunctions[renamedDeclaredFunction] = listOf(resultOfIntersectionWithNaturalName)
|
||||
for (overriddenMember in overriddenMembers) {
|
||||
@@ -508,9 +508,29 @@ class JavaClassUseSiteMemberScope(
|
||||
if (explicitlyDeclaredFunctionWithNaturalName != null) {
|
||||
destination += explicitlyDeclaredFunctionWithNaturalName
|
||||
}
|
||||
return true
|
||||
} else {
|
||||
val newSymbol = FirNamedFunctionSymbol(accidentalOverrideWithDeclaredFunction.callableId)
|
||||
val original = accidentalOverrideWithDeclaredFunction.fir
|
||||
val hiddenFunction = buildSimpleFunctionCopy(original) {
|
||||
name = naturalName
|
||||
symbol = newSymbol
|
||||
dispatchReceiverType = klass.defaultType()
|
||||
}.apply {
|
||||
initialSignatureAttr = original
|
||||
isHiddenToOvercomeSignatureClash = true
|
||||
}
|
||||
destination += hiddenFunction.symbol
|
||||
directOverriddenFunctions[hiddenFunction.symbol] = listOf(resultOfIntersectionWithNaturalName)
|
||||
for (overriddenMember in overriddenMembers) {
|
||||
overrideByBase[overriddenMember.member] = hiddenFunction.symbol
|
||||
}
|
||||
if (explicitlyDeclaredFunctionWithNaturalName != null) {
|
||||
destination += explicitlyDeclaredFunctionWithNaturalName
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private fun FirNamedFunctionSymbol.hasSameJvmDescriptor(
|
||||
|
||||
Reference in New Issue
Block a user