KT-11611 Prevent duplicate generation of default values of secondary constructor parameters
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
var global = 0
|
||||
|
||||
fun sideEffect() = global++
|
||||
|
||||
class A(val x: String) {
|
||||
constructor(y: Int = sideEffect(), z: (Int) -> Int = { it + sideEffect() }) : this("$y:${z(y)}") {}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var a = A()
|
||||
if (a.x != "0:1") return "failed1: ${a.x}"
|
||||
if (global != 2) return "failed2: ${global}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -12862,6 +12862,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("defaultParametersNotDuplicated.kt")
|
||||
public void testDefaultParametersNotDuplicated() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/secondaryConstructors/defaultParametersNotDuplicated.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("delegationWithPrimary.kt")
|
||||
public void testDelegationWithPrimary() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/secondaryConstructors/delegationWithPrimary.kt");
|
||||
|
||||
Reference in New Issue
Block a user