@@ -1868,13 +1868,12 @@ open class KotlinFileExtractor(
1868
1868
extractStaticTypeAccessQualifierUnchecked(overriddenCallTarget.parent, id, locId, enclosingCallable, enclosingStmt)
1869
1869
}
1870
1870
1871
- extractDefaultsCallArguments(id, overriddenCallTarget, locId, enclosingCallable, enclosingStmt, valueArguments, dispatchReceiver, extensionReceiver)
1871
+ extractDefaultsCallArguments(id, overriddenCallTarget, enclosingCallable, enclosingStmt, valueArguments, dispatchReceiver, extensionReceiver)
1872
1872
}
1873
1873
1874
1874
private fun extractDefaultsCallArguments (
1875
1875
id : Label <out DbExprparent >,
1876
1876
callTarget : IrFunction ,
1877
- locId : Label <DbLocation >,
1878
1877
enclosingCallable : Label <out DbCallable >,
1879
1878
enclosingStmt : Label <out DbStmt >,
1880
1879
valueArguments : List <IrExpression ?>,
@@ -1901,7 +1900,7 @@ open class KotlinFileExtractor(
1901
1900
IrConstImpl .defaultValueForType(0 , 0 , getDefaultsMethodLastArgType(callTarget))
1902
1901
)
1903
1902
1904
- extractCallValueArguments(id, valueArgsWithDummies + extraArgs, callTarget, locId, enclosingStmt, enclosingCallable, nextIdx, extractVarargAsArray = true )
1903
+ extractCallValueArguments(id, valueArgsWithDummies + extraArgs, enclosingStmt, enclosingCallable, nextIdx, extractVarargAsArray = true )
1905
1904
}
1906
1905
1907
1906
private fun getFunctionInvokeMethod (typeArgs : List <IrTypeArgument >): IrFunction ? {
@@ -2023,7 +2022,7 @@ open class KotlinFileExtractor(
2023
2022
childIdx,
2024
2023
enclosingStmt,
2025
2024
valueArguments.size,
2026
- { argParent, idxOffset -> extractCallValueArguments(argParent, valueArguments, syntacticCallTarget, locId, enclosingStmt, enclosingCallable, idxOffset) },
2025
+ { argParent, idxOffset -> extractCallValueArguments(argParent, valueArguments, enclosingStmt, enclosingCallable, idxOffset) },
2027
2026
dispatchReceiver?.type,
2028
2027
dispatchReceiver?.let { { callId -> extractExpressionExpr(dispatchReceiver, enclosingCallable, callId, - 1 , enclosingStmt) } },
2029
2028
extensionReceiver?.let { { argParent -> extractExpressionExpr(extensionReceiver, enclosingCallable, argParent, 0 , enclosingStmt) } },
@@ -2117,10 +2116,10 @@ open class KotlinFileExtractor(
2117
2116
this is IrEnumEntry
2118
2117
2119
2118
2120
- private fun extractCallValueArguments (callId : Label <out DbExprparent >, call : IrFunctionAccessExpression , callTarget : IrFunction , fallbackLocation : Label < DbLocation >, enclosingStmt : Label <out DbStmt >, enclosingCallable : Label <out DbCallable >, idxOffset : Int ) =
2121
- extractCallValueArguments(callId, (0 until call.valueArgumentsCount).map { call.getValueArgument(it) }, callTarget, fallbackLocation, enclosingStmt, enclosingCallable, idxOffset)
2119
+ private fun extractCallValueArguments (callId : Label <out DbExprparent >, call : IrFunctionAccessExpression , enclosingStmt : Label <out DbStmt >, enclosingCallable : Label <out DbCallable >, idxOffset : Int ) =
2120
+ extractCallValueArguments(callId, (0 until call.valueArgumentsCount).map { call.getValueArgument(it) }, enclosingStmt, enclosingCallable, idxOffset)
2122
2121
2123
- private fun extractCallValueArguments (callId : Label <out DbExprparent >, valueArguments : List <IrExpression ?>, callTarget : IrFunction , fallbackLocation : Label < DbLocation >, enclosingStmt : Label <out DbStmt >, enclosingCallable : Label <out DbCallable >, idxOffset : Int , extractVarargAsArray : Boolean = false) {
2122
+ private fun extractCallValueArguments (callId : Label <out DbExprparent >, valueArguments : List <IrExpression ?>, enclosingStmt : Label <out DbStmt >, enclosingCallable : Label <out DbCallable >, idxOffset : Int , extractVarargAsArray : Boolean = false) {
2124
2123
var i = 0
2125
2124
valueArguments.forEach { arg ->
2126
2125
if (arg != null ) {
@@ -2130,25 +2129,6 @@ open class KotlinFileExtractor(
2130
2129
} else {
2131
2130
extractExpressionExpr(arg, enclosingCallable, callId, (i++ ) + idxOffset, enclosingStmt)
2132
2131
}
2133
- } else {
2134
- val realCallTarget = callTarget.target.realOverrideTarget
2135
-
2136
- // Generated constructor calls to kotlin.Enum have no arguments in IR, but the constructor takes two parameters.
2137
- if (realCallTarget is IrConstructor &&
2138
- realCallTarget.parentClassOrNull?.fqNameWhenAvailable?.asString() == " kotlin.Enum" &&
2139
- realCallTarget.valueParameters.size == 2 &&
2140
- i < realCallTarget.valueParameters.size) {
2141
-
2142
- if (i == 0 && realCallTarget.valueParameters[i].type == pluginContext.irBuiltIns.stringType) {
2143
-
2144
- val id = extractNull(pluginContext.irBuiltIns.stringType, fallbackLocation, callId, (i++ ) + idxOffset, enclosingCallable, enclosingStmt)
2145
- tw.writeCompiler_generated(id, CompilerGeneratedKinds .ENUM_CONSTRUCTOR_ARGUMENT .kind)
2146
- } else if (i == 1 && realCallTarget.valueParameters[i].type == pluginContext.irBuiltIns.intType) {
2147
-
2148
- val id = extractConstantInteger(0 , fallbackLocation, callId, (i++ ) + idxOffset, enclosingCallable, enclosingStmt)
2149
- tw.writeCompiler_generated(id, CompilerGeneratedKinds .ENUM_CONSTRUCTOR_ARGUMENT .kind)
2150
- }
2151
- }
2152
2132
}
2153
2133
}
2154
2134
}
@@ -3083,15 +3063,31 @@ open class KotlinFileExtractor(
3083
3063
val isAnonymous = eType.isAnonymous
3084
3064
val locId = tw.getLocation(e)
3085
3065
val valueArgs = (0 until e.valueArgumentsCount).map { e.getValueArgument(it) }
3086
- // For now, don't try to use default methods for enum constructor calls,
3087
- // which have null arguments even though the parameters don't give default values.
3066
+
3088
3067
val id = if (e !is IrEnumConstructorCall && callUsesDefaultArguments(e.symbol.owner, valueArgs)) {
3089
3068
extractNewExpr(getDefaultsMethodLabel(e.symbol.owner).cast(), type, locId, parent, idx, callable, enclosingStmt).also {
3090
- extractDefaultsCallArguments(it, e.symbol.owner, locId, callable, enclosingStmt, valueArgs, null , null )
3069
+ extractDefaultsCallArguments(it, e.symbol.owner, callable, enclosingStmt, valueArgs, null , null )
3091
3070
}
3092
3071
} else {
3093
3072
extractNewExpr(e.symbol.owner, eType.arguments, type, locId, parent, idx, callable, enclosingStmt).also {
3094
- extractCallValueArguments(it, e, e.symbol.owner, locId, enclosingStmt, callable, 0 )
3073
+
3074
+ val realCallTarget = e.symbol.owner.realOverrideTarget
3075
+ // Generated constructor calls to kotlin.Enum have no arguments in IR, but the constructor takes two parameters.
3076
+ if (e is IrEnumConstructorCall &&
3077
+ realCallTarget is IrConstructor &&
3078
+ realCallTarget.parentClassOrNull?.fqNameWhenAvailable?.asString() == " kotlin.Enum" &&
3079
+ realCallTarget.valueParameters.size == 2 &&
3080
+ realCallTarget.valueParameters[0 ].type == pluginContext.irBuiltIns.stringType &&
3081
+ realCallTarget.valueParameters[1 ].type == pluginContext.irBuiltIns.intType) {
3082
+
3083
+ val id0 = extractNull(pluginContext.irBuiltIns.stringType, locId, it, 0 , callable, enclosingStmt)
3084
+ tw.writeCompiler_generated(id0, CompilerGeneratedKinds .ENUM_CONSTRUCTOR_ARGUMENT .kind)
3085
+
3086
+ val id1 = extractConstantInteger(0 , locId, it, 1 , callable, enclosingStmt)
3087
+ tw.writeCompiler_generated(id1, CompilerGeneratedKinds .ENUM_CONSTRUCTOR_ARGUMENT .kind)
3088
+ } else {
3089
+ extractCallValueArguments(it, e, enclosingStmt, callable, 0 )
3090
+ }
3095
3091
}
3096
3092
}
3097
3093
@@ -3464,7 +3460,7 @@ open class KotlinFileExtractor(
3464
3460
3465
3461
tw.writeHasLocation(id, locId)
3466
3462
tw.writeCallableBinding(id.cast<DbCaller >(), methodId)
3467
- extractCallValueArguments(id, e, e.symbol.owner, locId, id, callable, 0 )
3463
+ extractCallValueArguments(id, e, id, callable, 0 )
3468
3464
val dr = e.dispatchReceiver
3469
3465
if (dr != null ) {
3470
3466
extractExpressionExpr(dr, callable, id, - 1 , id)
0 commit comments