Retain data flow info after multi-declaration
#KT-2825 In Progress
This commit is contained in:
+5
-5
@@ -137,14 +137,14 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
||||
context.trace.report(INITIALIZER_REQUIRED_FOR_MULTIDECLARATION.on(multiDeclaration));
|
||||
return JetTypeInfo.create(null, context.dataFlowInfo);
|
||||
}
|
||||
final ExpressionReceiver expressionReceiver = ExpressionTypingUtils.getExpressionReceiver(facade, initializer,
|
||||
context.replaceExpectedType(
|
||||
TypeUtils.NO_EXPECTED_TYPE));
|
||||
final ExpressionReceiver expressionReceiver =
|
||||
ExpressionTypingUtils.getExpressionReceiver(facade, initializer, context.replaceExpectedType(TypeUtils.NO_EXPECTED_TYPE));
|
||||
DataFlowInfo dataFlowInfo = facade.getTypeInfo(initializer, context).getDataFlowInfo();
|
||||
if (expressionReceiver == null) {
|
||||
return JetTypeInfo.create(null, context.dataFlowInfo);
|
||||
return JetTypeInfo.create(null, dataFlowInfo);
|
||||
}
|
||||
ExpressionTypingUtils.defineLocalVariablesFromMultiDeclaration(scope, multiDeclaration, expressionReceiver, initializer, context);
|
||||
return DataFlowUtils.checkStatementType(multiDeclaration, context, context.dataFlowInfo);
|
||||
return DataFlowUtils.checkStatementType(multiDeclaration, context, dataFlowInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
fun Int.component1() = "a"
|
||||
|
||||
fun foo(a: Number) {
|
||||
val (x) = a as Int
|
||||
a : Int
|
||||
x : String
|
||||
}
|
||||
@@ -1241,6 +1241,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
doTest("compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfThenElseBothInvalid.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("MultiDeclaration.kt")
|
||||
public void testMultiDeclaration() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/dataFlowInfoTraversal/MultiDeclaration.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ObjectExpression.kt")
|
||||
public void testObjectExpression() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ObjectExpression.kt");
|
||||
|
||||
Reference in New Issue
Block a user