Skip to content

Commit 0ddd5bb

Browse files
authored
Merge pull request #9709 from igfoo/igfoo/isLocalFunction
Kotlin: Let useFunction worry about isLocalFunction for us
2 parents 9f58ba1 + c0b6d1d commit 0ddd5bb

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -732,12 +732,9 @@ open class KotlinFileExtractor(
732732

733733
val id =
734734
idOverride
735-
?: if (f.isLocalFunction())
736-
getLocallyVisibleFunctionLabels(f).function
737-
else
738-
// If this is a class that would ordinarily be replaced by a Java equivalent (e.g. kotlin.Map -> java.util.Map),
739-
// don't replace here, really extract the Kotlin version:
740-
useFunction<DbCallable>(f, parentId, classTypeArgsIncludingOuterClasses, noReplace = true)
735+
?: // If this is a class that would ordinarily be replaced by a Java equivalent (e.g. kotlin.Map -> java.util.Map),
736+
// don't replace here, really extract the Kotlin version:
737+
useFunction<DbCallable>(f, parentId, classTypeArgsIncludingOuterClasses, noReplace = true)
741738

742739
val sourceDeclaration =
743740
if (typeSubstitution != null && idOverride == null)

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,15 +1201,14 @@ open class KotlinUsesExtractor(
12011201
} as IrFunction? ?: f
12021202

12031203
fun <T: DbCallable> useFunction(f: IrFunction, classTypeArgsIncludingOuterClasses: List<IrTypeArgument>? = null, noReplace: Boolean = false): Label<out T> {
1204+
return useFunction(f, null, classTypeArgsIncludingOuterClasses, noReplace)
1205+
}
1206+
1207+
fun <T: DbCallable> useFunction(f: IrFunction, parentId: Label<out DbElement>?, classTypeArgsIncludingOuterClasses: List<IrTypeArgument>?, noReplace: Boolean = false): Label<out T> {
12041208
if (f.isLocalFunction()) {
12051209
val ids = getLocallyVisibleFunctionLabels(f)
12061210
return ids.function.cast<T>()
1207-
} else {
1208-
return useFunction(f, null, classTypeArgsIncludingOuterClasses, noReplace)
12091211
}
1210-
}
1211-
1212-
fun <T: DbCallable> useFunction(f: IrFunction, parentId: Label<out DbElement>?, classTypeArgsIncludingOuterClasses: List<IrTypeArgument>?, noReplace: Boolean = false): Label<out T> {
12131212
val javaFun = kotlinFunctionToJavaEquivalent(f, noReplace)
12141213
val label = getFunctionLabel(javaFun, parentId, classTypeArgsIncludingOuterClasses)
12151214
val id: Label<T> = tw.getLabelFor(label)

0 commit comments

Comments
 (0)