DataFLowInfo doesn't flow from when-checks
This commit is contained in:
+2
-3
@@ -51,13 +51,12 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor {
|
||||
ExpressionTypingContext context = contextWithExpectedType.replaceExpectedType(TypeUtils.NO_EXPECTED_TYPE);
|
||||
JetExpression leftHandSide = expression.getLeftHandSide();
|
||||
JetType knownType = facade.safeGetTypeInfo(leftHandSide, context.replaceScope(context.scope)).getType();
|
||||
DataFlowInfo newDataFlowInfo = context.dataFlowInfo;
|
||||
if (expression.getTypeRef() != null) {
|
||||
DataFlowValue dataFlowValue = DataFlowValueFactory.INSTANCE.createDataFlowValue(leftHandSide, knownType, context.trace.getBindingContext());
|
||||
newDataFlowInfo = checkTypeForIs(context, knownType, expression.getTypeRef(), dataFlowValue).thenInfo;
|
||||
DataFlowInfo newDataFlowInfo = checkTypeForIs(context, knownType, expression.getTypeRef(), dataFlowValue).thenInfo;
|
||||
context.trace.record(BindingContext.DATAFLOW_INFO_AFTER_CONDITION, expression, newDataFlowInfo);
|
||||
}
|
||||
return DataFlowUtils.checkType(JetStandardLibrary.getInstance().getBooleanType(), expression, contextWithExpectedType, newDataFlowInfo);
|
||||
return DataFlowUtils.checkType(JetStandardLibrary.getInstance().getBooleanType(), expression, contextWithExpectedType, context.dataFlowInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
fun f(<!UNUSED_PARAMETER!>a<!>: Boolean, <!UNUSED_PARAMETER!>b<!>: Int) {}
|
||||
|
||||
fun foo(a: Any) {
|
||||
f(a is Int, <!TYPE_MISMATCH!>a<!>)
|
||||
1 <!NONE_APPLICABLE!>+<!> a
|
||||
}
|
||||
@@ -15,13 +15,16 @@
|
||||
*/
|
||||
package org.jetbrains.jet.checkers;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import java.io.File;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.test.InnerTestClasses;
|
||||
import org.jetbrains.jet.test.TestMetadata;
|
||||
|
||||
import java.io.File;
|
||||
import org.jetbrains.jet.checkers.AbstractDiagnosticsTestWithEagerResolve;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.jet.checkers.AbstractDiagnosticsTestWithEagerResolve}. DO NOT MODIFY MANUALLY */
|
||||
@InnerTestClasses({JetDiagnosticsTestGenerated.Tests.class, JetDiagnosticsTestGenerated.Script.class, })
|
||||
@@ -947,6 +950,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
doTest("compiler/testData/diagnostics/tests/dataFlow/CalleeExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("IsExpression.kt")
|
||||
public void testIsExpression() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/dataFlow/IsExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("TupleExpression.kt")
|
||||
public void testTupleExpression() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/dataFlow/TupleExpression.kt");
|
||||
|
||||
Reference in New Issue
Block a user