Fix for KT-3969: Codegen fails on unary calls with default arguments
#KT-3969 Fixed
This commit is contained in:
@@ -3094,7 +3094,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
|
||||
Type type = expressionType(expression.getBaseExpression());
|
||||
value.put(type, v);
|
||||
callableMethod.invokeWithNotNullAssertion(v, state, resolvedCall);
|
||||
invokeFunction(resolvedCall, StackValue.onStack(type));
|
||||
|
||||
value.store(callableMethod.getReturnType(), v);
|
||||
value.put(type, v);
|
||||
@@ -3163,8 +3163,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
else {
|
||||
ResolvedCall<?> resolvedCall = getResolvedCallWithAssert(expression, bindingContext);
|
||||
Callable callable = resolveToCallable((FunctionDescriptor) op, false);
|
||||
invokeFunction(resolvedCall, StackValue.onStack(type));
|
||||
CallableMethod callableMethod = (CallableMethod) callable;
|
||||
callableMethod.invokeWithNotNullAssertion(v, state, resolvedCall);
|
||||
storeType = callableMethod.getReturnType();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
var result = "Fail"
|
||||
|
||||
class A
|
||||
|
||||
fun A.inc(s: String = "OK"): A {
|
||||
result = s
|
||||
return this
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var a = A()
|
||||
a++
|
||||
if (result != "OK") return "Fail 1"
|
||||
|
||||
result = "Fail"
|
||||
++a
|
||||
|
||||
return result
|
||||
}
|
||||
@@ -2777,6 +2777,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt3969.kt")
|
||||
public void testKt3969() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/extensionFunctions/kt3969.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt4118.kt")
|
||||
public void testKt4118() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/extensionFunctions/kt4118.kt");
|
||||
|
||||
Reference in New Issue
Block a user