Skip to content

Commit 6cc74da

Browse files
committed
Defaults function extraction: respect the extract-type-accesses flag
1 parent 34a0a0d commit 6cc74da

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -835,12 +835,12 @@ open class KotlinFileExtractor(
835835
forceExtractFunction(f, parentId, extractBody, extractMethodAndParameterTypeAccesses, typeSubstitution, classTypeArgsIncludingOuterClasses).also {
836836
// The defaults-forwarder function is a static utility, not a member, so we only need to extract this for the unspecialised instance of this class.
837837
if (classTypeArgsIncludingOuterClasses.isNullOrEmpty())
838-
extractDefaultsFunction(f, parentId, extractBody)
838+
extractDefaultsFunction(f, parentId, extractBody, extractMethodAndParameterTypeAccesses)
839839
extractGeneratedOverloads(f, parentId, null, extractBody, extractMethodAndParameterTypeAccesses, typeSubstitution, classTypeArgsIncludingOuterClasses)
840840
}
841841
}
842842

843-
private fun extractDefaultsFunction(f: IrFunction, parentId: Label<out DbReftype>, extractBody: Boolean) {
843+
private fun extractDefaultsFunction(f: IrFunction, parentId: Label<out DbReftype>, extractBody: Boolean, extractMethodAndParameterTypeAccesses: Boolean) {
844844
if (f.valueParameters.none { it.defaultValue != null })
845845
return
846846

@@ -852,7 +852,8 @@ open class KotlinFileExtractor(
852852
val allParamTypeResults = parameterTypes.mapIndexed { i, paramType ->
853853
val paramId = tw.getLabelFor<DbParam>(getValueParameterLabel(id, i))
854854
extractValueParameter(paramId, paramType, "p$i", locId, id, i, paramId, isVararg = false, syntheticParameterNames = true, isCrossinline = false, isNoinline = false).also {
855-
extractTypeAccess(useType(paramType), locId, paramId, -1)
855+
if (extractMethodAndParameterTypeAccesses)
856+
extractTypeAccess(useType(paramType), locId, paramId, -1)
856857
}
857858
}
858859
val paramsSignature = allParamTypeResults.joinToString(separator = ",", prefix = "(", postfix = ")") { it.javaResult.signature }
@@ -863,7 +864,7 @@ open class KotlinFileExtractor(
863864
extractConstructor(constrId, shortName, paramsSignature, parentId, constrId)
864865
} else {
865866
val methodId = id.cast<DbMethod>()
866-
extractMethod(methodId, locId, shortName, erase(f.returnType), paramsSignature, parentId, methodId, origin = null, extractTypeAccess = true)
867+
extractMethod(methodId, locId, shortName, erase(f.returnType), paramsSignature, parentId, methodId, origin = null, extractTypeAccess = extractMethodAndParameterTypeAccesses)
867868
addModifiers(id, "static")
868869
}
869870
tw.writeHasLocation(id, locId)

0 commit comments

Comments
 (0)