Pass builtIns into CompileTimeConstantChecker constructor
This commit is contained in:
+6
-2
@@ -43,9 +43,13 @@ public class CompileTimeConstantChecker {
|
|||||||
private final BindingTrace trace;
|
private final BindingTrace trace;
|
||||||
private final boolean checkOnlyErrorsThatDependOnExpectedType;
|
private final boolean checkOnlyErrorsThatDependOnExpectedType;
|
||||||
|
|
||||||
public CompileTimeConstantChecker(@NotNull BindingTrace trace, boolean checkOnlyErrorsThatDependOnExpectedType) {
|
public CompileTimeConstantChecker(
|
||||||
|
@NotNull BindingTrace trace,
|
||||||
|
@NotNull KotlinBuiltIns builtIns,
|
||||||
|
boolean checkOnlyErrorsThatDependOnExpectedType
|
||||||
|
) {
|
||||||
this.checkOnlyErrorsThatDependOnExpectedType = checkOnlyErrorsThatDependOnExpectedType;
|
this.checkOnlyErrorsThatDependOnExpectedType = checkOnlyErrorsThatDependOnExpectedType;
|
||||||
this.builtIns = KotlinBuiltIns.getInstance();
|
this.builtIns = builtIns;
|
||||||
this.trace = trace;
|
this.trace = trace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -120,9 +120,9 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (!(compileTimeConstant instanceof IntegerValueTypeConstant)) {
|
if (!(compileTimeConstant instanceof IntegerValueTypeConstant)) {
|
||||||
CompileTimeConstantChecker compileTimeConstantChecker = context.getCompileTimeConstantChecker();
|
CompileTimeConstantChecker constantChecker = new CompileTimeConstantChecker(context.trace, components.builtIns, false);
|
||||||
ConstantValue constantValue = compileTimeConstant != null ? ((TypedCompileTimeConstant) compileTimeConstant).getConstantValue() : null;
|
ConstantValue constantValue = compileTimeConstant != null ? ((TypedCompileTimeConstant) compileTimeConstant).getConstantValue() : null;
|
||||||
boolean hasError = compileTimeConstantChecker.checkConstantExpressionType(constantValue, expression, context.expectedType);
|
boolean hasError = constantChecker.checkConstantExpressionType(constantValue, expression, context.expectedType);
|
||||||
if (hasError) {
|
if (hasError) {
|
||||||
IElementType elementType = expression.getNode().getElementType();
|
IElementType elementType = expression.getNode().getElementType();
|
||||||
return TypeInfoFactoryPackage.createTypeInfo(getDefaultType(elementType), context);
|
return TypeInfoFactoryPackage.createTypeInfo(getDefaultType(elementType), context);
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ public class DataFlowAnalyzer {
|
|||||||
|
|
||||||
if (expression instanceof JetConstantExpression) {
|
if (expression instanceof JetConstantExpression) {
|
||||||
ConstantValue<?> constantValue = constantExpressionEvaluator.evaluateToConstantValue(expression, c.trace, c.expectedType);
|
ConstantValue<?> constantValue = constantExpressionEvaluator.evaluateToConstantValue(expression, c.trace, c.expectedType);
|
||||||
boolean error = new CompileTimeConstantChecker(c.trace, true)
|
boolean error = new CompileTimeConstantChecker(c.trace, builtIns, true)
|
||||||
.checkConstantExpressionType(constantValue, (JetConstantExpression) expression, c.expectedType);
|
.checkConstantExpressionType(constantValue, (JetConstantExpression) expression, c.expectedType);
|
||||||
if (hasError != null) hasError.set(error);
|
if (hasError != null) hasError.set(error);
|
||||||
return expressionType;
|
return expressionType;
|
||||||
|
|||||||
-11
@@ -83,8 +83,6 @@ public class ExpressionTypingContext extends ResolutionContext<ExpressionTypingC
|
|||||||
statementFilter, isAnnotationContext, false, false);
|
statementFilter, isAnnotationContext, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CompileTimeConstantChecker compileTimeConstantChecker;
|
|
||||||
|
|
||||||
private ExpressionTypingContext(
|
private ExpressionTypingContext(
|
||||||
@NotNull BindingTrace trace,
|
@NotNull BindingTrace trace,
|
||||||
@NotNull LexicalScope scope,
|
@NotNull LexicalScope scope,
|
||||||
@@ -120,13 +118,4 @@ public class ExpressionTypingContext extends ResolutionContext<ExpressionTypingC
|
|||||||
callChecker,
|
callChecker,
|
||||||
statementFilter, isAnnotationContext, collectAllCandidates, insideSafeCallChain);
|
statementFilter, isAnnotationContext, collectAllCandidates, insideSafeCallChain);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////// LAZY ACCESSORS
|
|
||||||
|
|
||||||
public CompileTimeConstantChecker getCompileTimeConstantChecker() {
|
|
||||||
if (compileTimeConstantChecker == null) {
|
|
||||||
compileTimeConstantChecker = new CompileTimeConstantChecker(trace, false);
|
|
||||||
}
|
|
||||||
return compileTimeConstantChecker;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user