Fixed bug with default args copying in enums + test
This commit is contained in:
+1
@@ -271,6 +271,7 @@ internal class EnumClassLowering(val context: Context) : ClassLoweringPass {
|
|||||||
val loweredArgument = loweredEnumConstructor.valueParameters[argument.loweredIndex()]
|
val loweredArgument = loweredEnumConstructor.valueParameters[argument.loweredIndex()]
|
||||||
val body = irConstructor.getDefault(loweredArgument)!!.deepCopyWithVariables()
|
val body = irConstructor.getDefault(loweredArgument)!!.deepCopyWithVariables()
|
||||||
body.transformChildrenVoid(ParameterMapper(constructor))
|
body.transformChildrenVoid(ParameterMapper(constructor))
|
||||||
|
body.accept(SetDeclarationsParentVisitor, irConstructor)
|
||||||
constructor.putDefault(constructorDescriptor.valueParameters[loweredArgument.index], body)
|
constructor.putDefault(constructorDescriptor.valueParameters[loweredArgument.index], body)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -774,6 +774,11 @@ task switchLowering(type: RunKonanTest) {
|
|||||||
source = "codegen/enum/switchLowering.kt"
|
source = "codegen/enum/switchLowering.kt"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task enum_lambdaInDefault(type: RunKonanTest) {
|
||||||
|
goldValue = "Q\n"
|
||||||
|
source = "codegen/enum/lambdaInDefault.kt"
|
||||||
|
}
|
||||||
|
|
||||||
task mangling(type: LinkKonanTest) {
|
task mangling(type: LinkKonanTest) {
|
||||||
goldValue =
|
goldValue =
|
||||||
"Int direct [1, 2, 3, 4]\n" +
|
"Int direct [1, 2, 3, 4]\n" +
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package codegen.enum.lambdaInDefault
|
||||||
|
|
||||||
|
import kotlin.test.*
|
||||||
|
|
||||||
|
enum class Zzz(val value: String.() -> Int = {
|
||||||
|
length
|
||||||
|
}) {
|
||||||
|
Q()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun runTest() {
|
||||||
|
println(Zzz.Q)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user