Skip to content

Commit 5c36e63

Browse files
committed
Kotlin: Fix findTopLevelFunctionOrWarn for Kotlin 2
The AST when the parent class is a file class is different in Kotlin 2 mode.
1 parent 8a8031d commit 5c36e63

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,8 +2457,12 @@ open class KotlinFileExtractor(
24572457

24582458
val fn = getFunctionsByFqName(pluginContext, functionPkg, functionName)
24592459
.firstOrNull { fnSymbol ->
2460-
fnSymbol.owner.parentClassOrNull?.fqNameWhenAvailable?.asString() == type &&
2461-
fnSymbol.owner.valueParameters.map { it.type.classFqName?.asString() }.toTypedArray() contentEquals parameterTypes
2460+
val owner = fnSymbol.owner
2461+
(owner.parentClassOrNull?.fqNameWhenAvailable?.asString() == type
2462+
||
2463+
(owner.parent is IrExternalPackageFragment && getFileClassFqName(owner)?.asString() == type))
2464+
&&
2465+
owner.valueParameters.map { it.type.classFqName?.asString() }.toTypedArray() contentEquals parameterTypes
24622466
}?.owner
24632467

24642468
if (fn != null) {

0 commit comments

Comments
 (0)