Skip to content

Commit 6be4afc

Browse files
committed
Kotlin: extractValueParameter: Simplify typeSubstitution logic
The type substitution is now done in the wrapper, so the worker doesn't need to be passed typeSubstitution.
1 parent ed9e798 commit 6be4afc

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -497,17 +497,17 @@ open class KotlinFileExtractor(
497497
else
498498
null
499499
} ?: vp.type
500+
val substitutedType = typeSubstitution?.let { it(maybeErasedType, TypeContext.OTHER, pluginContext) } ?: maybeErasedType
500501
val id = useValueParameter(vp, parent)
501502
if (extractTypeAccess) {
502-
extractTypeAccessRecursive(typeSubstitution?.let { it(maybeErasedType, TypeContext.OTHER, pluginContext) } ?: maybeErasedType, location, id, -1)
503+
extractTypeAccessRecursive(substitutedType, location, id, -1)
503504
}
504-
return extractValueParameter(id, maybeErasedType, vp.name.asString(), location, parent, idx, typeSubstitution, useValueParameter(vp, parentSourceDeclaration), vp.isVararg)
505+
return extractValueParameter(id, substitutedType, vp.name.asString(), location, parent, idx, useValueParameter(vp, parentSourceDeclaration), vp.isVararg)
505506
}
506507
}
507508

508-
private fun extractValueParameter(id: Label<out DbParam>, t: IrType, name: String, locId: Label<DbLocation>, parent: Label<out DbCallable>, idx: Int, typeSubstitution: TypeSubstitution?, paramSourceDeclaration: Label<out DbParam>, isVararg: Boolean): TypeResults {
509-
val substitutedType = typeSubstitution?.let { it(t, TypeContext.OTHER, pluginContext) } ?: t
510-
val type = useType(substitutedType)
509+
private fun extractValueParameter(id: Label<out DbParam>, t: IrType, name: String, locId: Label<DbLocation>, parent: Label<out DbCallable>, idx: Int, paramSourceDeclaration: Label<out DbParam>, isVararg: Boolean): TypeResults {
510+
val type = useType(t)
511511
tw.writeParams(id, type.javaResult.id, idx, parent, paramSourceDeclaration)
512512
tw.writeParamsKotlinType(id, type.kotlinResult.id)
513513
tw.writeHasLocation(id, locId)
@@ -2930,7 +2930,7 @@ open class KotlinFileExtractor(
29302930
stmtIdx: Int
29312931
) {
29322932
val paramId = tw.getFreshIdLabel<DbParam>()
2933-
val paramTypeRes = extractValueParameter(paramId, paramType, paramName, locId, ids.constructor, paramIdx, null, paramId, false)
2933+
val paramTypeRes = extractValueParameter(paramId, paramType, paramName, locId, ids.constructor, paramIdx, paramId, false)
29342934

29352935
val assignmentStmtId = tw.getFreshIdLabel<DbExprstmt>()
29362936
tw.writeStmts_exprstmt(assignmentStmtId, ids.constructorBlock, stmtIdx, ids.constructor)
@@ -3566,7 +3566,7 @@ open class KotlinFileExtractor(
35663566

35673567
val parameters = parameterTypes.mapIndexed { idx, p ->
35683568
val paramId = tw.getFreshIdLabel<DbParam>()
3569-
val paramType = extractValueParameter(paramId, p, "a$idx", locId, methodId, idx, null, paramId, false)
3569+
val paramType = extractValueParameter(paramId, p, "a$idx", locId, methodId, idx, paramId, false)
35703570

35713571
Pair(paramId, paramType)
35723572
}

0 commit comments

Comments
 (0)