Fix tests (by extracting a method and calling it multiple times)
This commit is contained in:
+6
-4
@@ -754,10 +754,6 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
JetExpression right = expression.getRight();
|
||||
IElementType operationType = operationSign.getReferencedNameElementType();
|
||||
|
||||
JetTypeInfo leftTypeInfo = left != null
|
||||
? facade.getTypeInfo(left, context)
|
||||
: JetTypeInfo.create(null, context.dataFlowInfo);
|
||||
|
||||
JetType result = null;
|
||||
DataFlowInfo dataFlowInfo = context.dataFlowInfo;
|
||||
|
||||
@@ -801,6 +797,8 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
if (right != null && left != null) {
|
||||
ExpressionReceiver receiver = ExpressionTypingUtils.safeGetExpressionReceiver(facade, left, context);
|
||||
|
||||
JetTypeInfo leftTypeInfo = getTypeInfoOrNullType(left, context, facade);
|
||||
|
||||
dataFlowInfo = leftTypeInfo.getDataFlowInfo();
|
||||
ExpressionTypingContext contextWithDataFlow = context.replaceDataFlowInfo(dataFlowInfo);
|
||||
|
||||
@@ -843,6 +841,8 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
result = typeInfo.getType();
|
||||
}
|
||||
else if (OperatorConventions.BOOLEAN_OPERATIONS.containsKey(operationType)) {
|
||||
JetTypeInfo leftTypeInfo = getTypeInfoOrNullType(left, context, facade);
|
||||
|
||||
JetType leftType = leftTypeInfo.getType();
|
||||
dataFlowInfo = leftTypeInfo.getDataFlowInfo();
|
||||
|
||||
@@ -865,6 +865,8 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
result = booleanType;
|
||||
}
|
||||
else if (operationType == JetTokens.ELVIS) {
|
||||
JetTypeInfo leftTypeInfo = getTypeInfoOrNullType(left, context, facade);
|
||||
|
||||
JetType leftType = leftTypeInfo.getType();
|
||||
dataFlowInfo = leftTypeInfo.getDataFlowInfo();
|
||||
|
||||
|
||||
+11
@@ -467,4 +467,15 @@ public class ExpressionTypingUtils {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JetTypeInfo getTypeInfoOrNullType(
|
||||
@Nullable JetExpression expression,
|
||||
@NotNull ExpressionTypingContext context,
|
||||
@NotNull ExpressionTypingInternals facade
|
||||
) {
|
||||
return expression != null
|
||||
? facade.getTypeInfo(expression, context)
|
||||
: JetTypeInfo.create(null, context.dataFlowInfo);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-6
@@ -209,9 +209,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
||||
JetSimpleNameExpression operationSign = expression.getOperationReference();
|
||||
IElementType operationType = operationSign.getReferencedNameElementType();
|
||||
JetExpression leftOperand = expression.getLeft();
|
||||
JetTypeInfo leftInfo = leftOperand != null
|
||||
? facade.getTypeInfo(leftOperand, context)
|
||||
: JetTypeInfo.create(null, context.dataFlowInfo);
|
||||
JetTypeInfo leftInfo = ExpressionTypingUtils.getTypeInfoOrNullType(leftOperand, context, facade);
|
||||
JetType leftType = leftInfo.getType();
|
||||
DataFlowInfo dataFlowInfo = leftInfo.getDataFlowInfo();
|
||||
|
||||
@@ -294,9 +292,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
||||
return JetTypeInfo.create(checkAssignmentType(typeInfo.getType(), expression, contextWithExpectedType),
|
||||
typeInfo.getDataFlowInfo());
|
||||
}
|
||||
JetTypeInfo leftInfo = leftOperand != null
|
||||
? facade.getTypeInfo(leftOperand, context)
|
||||
: JetTypeInfo.create(null, context.dataFlowInfo);
|
||||
JetTypeInfo leftInfo = ExpressionTypingUtils.getTypeInfoOrNullType(left, context, facade);
|
||||
JetType leftType = leftInfo.getType();
|
||||
DataFlowInfo dataFlowInfo = leftInfo.getDataFlowInfo();
|
||||
if (right != null) {
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fun test(x: Int?) {
|
||||
<!TYPE_MISMATCH!>x<!> in 1..2
|
||||
}
|
||||
@@ -16,17 +16,14 @@
|
||||
|
||||
package org.jetbrains.jet.checkers;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.test.InnerTestClasses;
|
||||
import org.jetbrains.jet.test.TestMetadata;
|
||||
|
||||
import org.jetbrains.jet.checkers.AbstractDiagnosticsTestWithEagerResolve;
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@@ -3050,6 +3047,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
doTest("compiler/testData/diagnostics/tests/nullableTypes/nullAssertOnTypeWithNullableUpperBound.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullableArgumentForIn.kt")
|
||||
public void testNullableArgumentForIn() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/nullableTypes/nullableArgumentForIn.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("redundantNullable.kt")
|
||||
public void testRedundantNullable() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/nullableTypes/redundantNullable.kt");
|
||||
|
||||
Reference in New Issue
Block a user