Skip to content

Commit 703ced3

Browse files
authored
Merge pull request github#9390 from igfoo/igfoo/valueparam
Kotlin: extractValueParameter: Simplify typeSubstitution logic
2 parents 729cf79 + 6be4afc commit 703ced3

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)
@@ -2931,7 +2931,7 @@ open class KotlinFileExtractor(
29312931
stmtIdx: Int
29322932
) {
29332933
val paramId = tw.getFreshIdLabel<DbParam>()
2934-
val paramTypeRes = extractValueParameter(paramId, paramType, paramName, locId, ids.constructor, paramIdx, null, paramId, false)
2934+
val paramTypeRes = extractValueParameter(paramId, paramType, paramName, locId, ids.constructor, paramIdx, paramId, false)
29352935

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

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

35723572
Pair(paramId, paramType)
35733573
}

0 commit comments

Comments
 (0)