Use OperatorConventions.BOOLEAN_OPERATIONS in frontend.
This commit is contained in:
+1
-1
@@ -987,7 +987,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
checkInExpression(expression, expression.getOperationReference(), expression.getLeft(), expression.getRight(), context);
|
||||
result = booleanType;
|
||||
}
|
||||
else if (operationType == JetTokens.ANDAND || operationType == JetTokens.OROR) {
|
||||
else if (OperatorConventions.BOOLEAN_OPERATIONS.containsKey(operationType)) {
|
||||
JetType leftType = facade.getTypeInfo(left, context.replaceScope(context.scope)).getType();
|
||||
WritableScopeImpl leftScope = newWritableScopeImpl(context, "Left scope of && or ||");
|
||||
DataFlowInfo flowInfoLeft = DataFlowUtils.extractDataFlowInfoFromCondition(left, operationType == JetTokens.ANDAND, leftScope, context); // TODO: This gets computed twice: here and in extractDataFlowInfoFromCondition() for the whole condition
|
||||
|
||||
@@ -27,11 +27,11 @@ import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowValue;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowValueFactory;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.types.JetTypeInfo;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.JetTypeInfo;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import java.util.List;
|
||||
@@ -70,7 +70,7 @@ public class DataFlowUtils {
|
||||
@Override
|
||||
public void visitBinaryExpression(JetBinaryExpression expression) {
|
||||
IElementType operationToken = expression.getOperationToken();
|
||||
if (operationToken == JetTokens.ANDAND || operationToken == JetTokens.OROR) {
|
||||
if (OperatorConventions.BOOLEAN_OPERATIONS.containsKey(operationToken)) {
|
||||
WritableScope actualScopeToExtend;
|
||||
if (operationToken == JetTokens.ANDAND) {
|
||||
actualScopeToExtend = conditionValue ? scopeToExtend : null;
|
||||
|
||||
-1
@@ -99,7 +99,6 @@ public class OperatorConventions {
|
||||
.put(JetTokens.MINUSEQ, JetTokens.MINUS)
|
||||
.build();
|
||||
|
||||
//TODO: use these across frontend
|
||||
public static final ImmutableBiMap<JetToken, Name> BOOLEAN_OPERATIONS = ImmutableBiMap.<JetToken, Name>builder()
|
||||
.put(JetTokens.ANDAND, Name.identifier("and"))
|
||||
.put(JetTokens.OROR, Name.identifier("or"))
|
||||
|
||||
Reference in New Issue
Block a user