Use type from compile time value for binary expression
This commit is contained in:
+6
-1
@@ -99,7 +99,12 @@ public class ConstantExpressionEvaluator private (val trace: BindingTrace) : Jet
|
||||
override fun visitParenthesizedExpression(expression: JetParenthesizedExpression, expectedType: JetType?): CompileTimeConstant<*>? {
|
||||
val deparenthesizedExpression = JetPsiUtil.deparenthesize(expression)
|
||||
if (deparenthesizedExpression != null && deparenthesizedExpression != expression) {
|
||||
return evaluate(deparenthesizedExpression, expectedType)
|
||||
val compileTimeConstant = evaluate(deparenthesizedExpression, expectedType)
|
||||
val isDeparentesizedPure = trace.get(BindingContext.IS_PURE_CONSTANT_EXPRESSION, deparenthesizedExpression)
|
||||
if (isDeparentesizedPure != null && isDeparentesizedPure!!) {
|
||||
trace.record(BindingContext.IS_PURE_CONSTANT_EXPRESSION, expression, true)
|
||||
}
|
||||
return compileTimeConstant
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -359,7 +359,7 @@ public class CandidateResolver {
|
||||
return;
|
||||
}
|
||||
if (storedContextForArgument == null) {
|
||||
JetType type = argumentTypeResolver.updateResultArgumentTypeIfNotDenotable(context, expression);
|
||||
JetType type = ArgumentTypeResolver.updateResultArgumentTypeIfNotDenotable(context, expression);
|
||||
checkResultArgumentType(type, argument, context);
|
||||
return;
|
||||
}
|
||||
@@ -372,7 +372,13 @@ public class CandidateResolver {
|
||||
}
|
||||
else {
|
||||
completeNestedCallsInference(contextForArgument);
|
||||
type = contextForArgument.candidateCall.getResultingDescriptor().getReturnType();
|
||||
JetType recordedType = context.trace.get(BindingContext.EXPRESSION_TYPE, expression);
|
||||
if (recordedType != null && !recordedType.getConstructor().isDenotable()) {
|
||||
type = ArgumentTypeResolver.updateResultArgumentTypeIfNotDenotable(context, expression);
|
||||
}
|
||||
else {
|
||||
type = contextForArgument.candidateCall.getResultingDescriptor().getReturnType();
|
||||
}
|
||||
checkValueArgumentTypes(contextForArgument);
|
||||
}
|
||||
JetType result = BindingContextUtils.updateRecordedType(
|
||||
|
||||
+5
@@ -855,6 +855,11 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
context.trace.report(UNSUPPORTED.on(operationSign, "Unknown operation"));
|
||||
result = JetTypeInfo.create(null, context.dataFlowInfo);
|
||||
}
|
||||
CompileTimeConstant<?> value = ConstantExpressionEvaluator.object$.
|
||||
evaluate(expression, contextWithExpectedType.trace, contextWithExpectedType.expectedType);
|
||||
if (value != null) {
|
||||
return createCompileTimeConstantTypeInfo(value, expression, contextWithExpectedType);
|
||||
}
|
||||
return DataFlowUtils.checkType(result, expression, contextWithExpectedType);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user