From 6be4afcf362d41c4cab07a8ba4ea9c99f9c0e000 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Tue, 31 May 2022 19:23:54 +0100 Subject: [PATCH] Kotlin: extractValueParameter: Simplify typeSubstitution logic The type substitution is now done in the wrapper, so the worker doesn't need to be passed typeSubstitution. --- .../src/main/kotlin/KotlinFileExtractor.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt index c47e14cb0fd..0caf2922d6f 100644 --- a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt +++ b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt @@ -497,17 +497,17 @@ open class KotlinFileExtractor( else null } ?: vp.type + val substitutedType = typeSubstitution?.let { it(maybeErasedType, TypeContext.OTHER, pluginContext) } ?: maybeErasedType val id = useValueParameter(vp, parent) if (extractTypeAccess) { - extractTypeAccessRecursive(typeSubstitution?.let { it(maybeErasedType, TypeContext.OTHER, pluginContext) } ?: maybeErasedType, location, id, -1) + extractTypeAccessRecursive(substitutedType, location, id, -1) } - return extractValueParameter(id, maybeErasedType, vp.name.asString(), location, parent, idx, typeSubstitution, useValueParameter(vp, parentSourceDeclaration), vp.isVararg) + return extractValueParameter(id, substitutedType, vp.name.asString(), location, parent, idx, useValueParameter(vp, parentSourceDeclaration), vp.isVararg) } } - private fun extractValueParameter(id: Label, t: IrType, name: String, locId: Label, parent: Label, idx: Int, typeSubstitution: TypeSubstitution?, paramSourceDeclaration: Label, isVararg: Boolean): TypeResults { - val substitutedType = typeSubstitution?.let { it(t, TypeContext.OTHER, pluginContext) } ?: t - val type = useType(substitutedType) + private fun extractValueParameter(id: Label, t: IrType, name: String, locId: Label, parent: Label, idx: Int, paramSourceDeclaration: Label, isVararg: Boolean): TypeResults { + val type = useType(t) tw.writeParams(id, type.javaResult.id, idx, parent, paramSourceDeclaration) tw.writeParamsKotlinType(id, type.kotlinResult.id) tw.writeHasLocation(id, locId) @@ -2930,7 +2930,7 @@ open class KotlinFileExtractor( stmtIdx: Int ) { val paramId = tw.getFreshIdLabel() - val paramTypeRes = extractValueParameter(paramId, paramType, paramName, locId, ids.constructor, paramIdx, null, paramId, false) + val paramTypeRes = extractValueParameter(paramId, paramType, paramName, locId, ids.constructor, paramIdx, paramId, false) val assignmentStmtId = tw.getFreshIdLabel() tw.writeStmts_exprstmt(assignmentStmtId, ids.constructorBlock, stmtIdx, ids.constructor) @@ -3566,7 +3566,7 @@ open class KotlinFileExtractor( val parameters = parameterTypes.mapIndexed { idx, p -> val paramId = tw.getFreshIdLabel() - val paramType = extractValueParameter(paramId, p, "a$idx", locId, methodId, idx, null, paramId, false) + val paramType = extractValueParameter(paramId, p, "a$idx", locId, methodId, idx, paramId, false) Pair(paramId, paramType) }