diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java index 608ace76096..276c7c395f2 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java @@ -981,7 +981,17 @@ public class JetControlFlowProcessor { generateInstructions(defaultValue); builder.bindLabel(skipDefaultValue); } - generateInitializer(parameter, createSyntheticValue(parameter)); + generateInitializer(parameter, computePseudoValueForParameter(parameter)); + } + + @NotNull + private PseudoValue computePseudoValueForParameter(@NotNull JetParameter parameter) { + PseudoValue syntheticValue = createSyntheticValue(parameter); + PseudoValue defaultValue = builder.getBoundValue(parameter.getDefaultValue()); + if (defaultValue == null) { + return syntheticValue; + } + return builder.merge(parameter, Lists.newArrayList(defaultValue, syntheticValue)).getOutputValue(); } @Override diff --git a/compiler/testData/cfg/functions/DefaultValuesForArguments.instructions b/compiler/testData/cfg/functions/DefaultValuesForArguments.instructions index a42371f93ab..c7177b5ce53 100644 --- a/compiler/testData/cfg/functions/DefaultValuesForArguments.instructions +++ b/compiler/testData/cfg/functions/DefaultValuesForArguments.instructions @@ -1,5 +1,5 @@ == foo == -fun foo(i: Int = 1) = i + 2 +fun foo(i: Int = 1, j: Int) = i + j --------------------- L0: 1 @@ -8,11 +8,15 @@ L0: r(1) -> L2 [after default value for parameter i]: magic(i: Int = 1) -> PREV:[jmp?(L2 [after default value for parameter i]), r(1) -> ] - w(i|) - r(i) -> - r(2) -> - mark(i + 2) - call(+, plus|, ) -> + merge(i: Int = 1|, ) -> + w(i|) + v(j: Int) + magic(j: Int) -> + w(j|) + r(i) -> + r(j) -> + mark(i + j) + call(+, plus|, ) -> L1: NEXT:[] error: diff --git a/compiler/testData/cfg/functions/DefaultValuesForArguments.kt b/compiler/testData/cfg/functions/DefaultValuesForArguments.kt index 3b6a8f9835c..29b4d4e0d46 100644 --- a/compiler/testData/cfg/functions/DefaultValuesForArguments.kt +++ b/compiler/testData/cfg/functions/DefaultValuesForArguments.kt @@ -1 +1 @@ -fun foo(i: Int = 1) = i + 2 \ No newline at end of file +fun foo(i: Int = 1, j: Int) = i + j \ No newline at end of file diff --git a/compiler/testData/cfg/functions/DefaultValuesForArguments.values b/compiler/testData/cfg/functions/DefaultValuesForArguments.values index 4c5426bd1d6..ce90d8c6d3c 100644 --- a/compiler/testData/cfg/functions/DefaultValuesForArguments.values +++ b/compiler/testData/cfg/functions/DefaultValuesForArguments.values @@ -1,8 +1,9 @@ == foo == -fun foo(i: Int = 1) = i + 2 +fun foo(i: Int = 1, j: Int) = i + j --------------------- -1 NEW() -i NEW() -2 NEW() -i + 2 NEW(, ) +1 NEW() +i: Int = 1 NEW(, ) +i NEW() +j NEW() +i + j NEW(, ) =====================