[JS IR] Fix clashes between bridge and delegated function call
The patch fixes the js function signature rules to avoid clashes between bridge and delegated call. Use overridden symbols dfs of JsName annotation in order to get the correct bridge name. ^KT-52968 Fixed
This commit is contained in:
committed by
Space
parent
6525f7a7ac
commit
caa1570e25
+3
-1
@@ -146,8 +146,10 @@ abstract class BridgesConstruction<T : JsCommonBackendContext>(val context: T) :
|
||||
copyReceiverParametersFrom(bridge, substitutionMap)
|
||||
copyValueParametersFrom(bridge, substitutionMap)
|
||||
annotations += bridge.annotations
|
||||
overriddenSymbols += delegateTo.overriddenSymbols
|
||||
// the js function signature building process (jsFunctionSignature()) uses dfs throught overriddenSymbols for getting js name,
|
||||
// therefore it is very important to put bridge symbol at the beginning, it allows to get correct js function name
|
||||
overriddenSymbols += bridge.symbol
|
||||
overriddenSymbols += delegateTo.overriddenSymbols
|
||||
}
|
||||
|
||||
irFunction.body = context.irFactory.createBlockBody(UNDEFINED_OFFSET, UNDEFINED_OFFSET) {
|
||||
|
||||
+14
-2
@@ -66,13 +66,25 @@ fun IrAnnotationContainer.isJsNativeInvoke(): Boolean = hasAnnotation(JsAnnotati
|
||||
|
||||
fun IrAnnotationContainer.isAnnotatedWithJsFun(): Boolean = hasAnnotation(JsAnnotations.jsFunFqn)
|
||||
|
||||
private fun IrOverridableDeclaration<*>.dfsOverridableJsNameOrNull(): String? {
|
||||
for (overriddenSymbol in overriddenSymbols) {
|
||||
val symbolOwner = overriddenSymbol.owner
|
||||
if (symbolOwner is IrAnnotationContainer) {
|
||||
symbolOwner.getJsName()?.let { return it }
|
||||
}
|
||||
if (symbolOwner is IrOverridableDeclaration<*>) {
|
||||
symbolOwner.dfsOverridableJsNameOrNull()?.let { return it }
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun IrDeclarationWithName.getJsNameForOverriddenDeclaration(): String? {
|
||||
val jsName = getJsName()
|
||||
|
||||
return when {
|
||||
jsName != null -> jsName
|
||||
this is IrOverridableDeclaration<*> ->
|
||||
overriddenSymbols.firstNotNullOfOrNull { (it.owner as? IrAnnotationContainer)?.getJsName() }
|
||||
this is IrOverridableDeclaration<*> -> dfsOverridableJsNameOrNull()
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user