KT-36956 fix back-end part in JVM and JVM_IR
PSI2IR: deparenthesize LHS expression when generating assignment receiver. FE: record 'set' operator call for code generation.
This commit is contained in:
+12
-3
@@ -956,7 +956,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
IElementType operationType = operationExpression.getOperationReference().getReferencedNameElementType();
|
||||
if (KtTokens.AUGMENTED_ASSIGNMENTS.contains(operationType)
|
||||
|| operationType == KtTokens.PLUSPLUS || operationType == KtTokens.MINUSMINUS) {
|
||||
ResolvedCall<?> resolvedCall = traceWithIndexedLValue.get(INDEXED_LVALUE_SET, expression);
|
||||
ResolvedCall<FunctionDescriptor> resolvedCall = traceWithIndexedLValue.get(INDEXED_LVALUE_SET, expression);
|
||||
if (resolvedCall != null && trace.wantsDiagnostics()) {
|
||||
// Call must be validated with the actual, not temporary trace in order to report operator diagnostic
|
||||
// Only unary assignment expressions (++, --) and +=/... must be checked, normal assignments have the proper trace
|
||||
@@ -971,6 +971,10 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
for (CallChecker checker : components.callCheckers) {
|
||||
checker.check(resolvedCall, expression, callCheckerContext);
|
||||
}
|
||||
// Should make sure resolved call for 'set' operator is recorded, see KT-36956.
|
||||
if (trace.get(INDEXED_LVALUE_SET, expression) == null) {
|
||||
trace.record(INDEXED_LVALUE_SET, expression, resolvedCall);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1766,8 +1770,13 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
traceForResolveResult.report(isGet ? NO_GET_METHOD.on(arrayAccessExpression) : NO_SET_METHOD.on(arrayAccessExpression));
|
||||
return resultTypeInfo.clearType();
|
||||
}
|
||||
traceForResolveResult.record(isGet ? INDEXED_LVALUE_GET : INDEXED_LVALUE_SET, arrayAccessExpression,
|
||||
functionResults.getResultingCall());
|
||||
|
||||
if (isGet) {
|
||||
traceForResolveResult.record(INDEXED_LVALUE_GET, arrayAccessExpression, functionResults.getResultingCall());
|
||||
} else {
|
||||
traceForResolveResult.record(INDEXED_LVALUE_SET, arrayAccessExpression, functionResults.getResultingCall());
|
||||
}
|
||||
|
||||
return resultTypeInfo.replaceType(functionResults.getResultingDescriptor().getReturnType());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user