Kotlin: Fix findTopLevelFunctionOrWarn for Kotlin 2

The AST when the parent class is a file class is different in
Kotlin 2 mode.
This commit is contained in:
Ian Lynagh
2023-10-31 13:54:37 +00:00
parent 8a8031df0e
commit 5c36e63dfe

View File

@@ -2457,8 +2457,12 @@ open class KotlinFileExtractor(
val fn = getFunctionsByFqName(pluginContext, functionPkg, functionName)
.firstOrNull { fnSymbol ->
fnSymbol.owner.parentClassOrNull?.fqNameWhenAvailable?.asString() == type &&
fnSymbol.owner.valueParameters.map { it.type.classFqName?.asString() }.toTypedArray() contentEquals parameterTypes
val owner = fnSymbol.owner
(owner.parentClassOrNull?.fqNameWhenAvailable?.asString() == type
||
(owner.parent is IrExternalPackageFragment && getFileClassFqName(owner)?.asString() == type))
&&
owner.valueParameters.map { it.type.classFqName?.asString() }.toTypedArray() contentEquals parameterTypes
}?.owner
if (fn != null) {