Fixed bug with default args copying in enums + test

This commit is contained in:
Igor Chevdar
2018-06-25 17:07:41 +03:00
parent 35be7055e1
commit 5e59045352
3 changed files with 19 additions and 0 deletions
@@ -271,6 +271,7 @@ internal class EnumClassLowering(val context: Context) : ClassLoweringPass {
val loweredArgument = loweredEnumConstructor.valueParameters[argument.loweredIndex()]
val body = irConstructor.getDefault(loweredArgument)!!.deepCopyWithVariables()
body.transformChildrenVoid(ParameterMapper(constructor))
body.accept(SetDeclarationsParentVisitor, irConstructor)
constructor.putDefault(constructorDescriptor.valueParameters[loweredArgument.index], body)
}
}
+5
View File
@@ -774,6 +774,11 @@ task switchLowering(type: RunKonanTest) {
source = "codegen/enum/switchLowering.kt"
}
task enum_lambdaInDefault(type: RunKonanTest) {
goldValue = "Q\n"
source = "codegen/enum/lambdaInDefault.kt"
}
task mangling(type: LinkKonanTest) {
goldValue =
"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)
}