Fix erroneous check when saving EXPRESSION_DATA_FLOW_INFO

Before saving a data flow info, we checked if it's the same as that of context,
which was passed to us. This proves wrong when eventually somebody asks for a
data flow info of the same expression, but with a different context (i.e. with
a different data flow info in it) and we return this (different) context's
info, whereas we should have returned that of the original context.
This could've happened in CandidateResolver, for example.

Save data flow info after every expression now, only if it's not empty.

No new tests added, see next commit.
This commit is contained in:
Alexander Udalov
2012-11-13 15:01:38 +04:00
parent ac7ee9d3f5
commit 7c0ea67356
@@ -117,7 +117,7 @@ public class ExpressionTypingVisitorDispatcher extends JetVisitor<JetTypeInfo, E
if (context.trace.get(BindingContext.PROCESSED, expression)) {
DataFlowInfo dataFlowInfo = context.trace.get(BindingContext.EXPRESSION_DATA_FLOW_INFO, expression);
if (dataFlowInfo == null) {
dataFlowInfo = context.dataFlowInfo;
dataFlowInfo = DataFlowInfo.EMPTY;
}
return JetTypeInfo.create(context.trace.getBindingContext().get(BindingContext.EXPRESSION_TYPE, expression), dataFlowInfo);
}
@@ -147,7 +147,7 @@ public class ExpressionTypingVisitorDispatcher extends JetVisitor<JetTypeInfo, E
context.trace.record(BindingContext.RESOLUTION_SCOPE, expression, context.scope);
}
context.trace.record(BindingContext.PROCESSED, expression);
if (result.getDataFlowInfo() != context.dataFlowInfo) {
if (result.getDataFlowInfo() != DataFlowInfo.EMPTY) {
context.trace.record(BindingContext.EXPRESSION_DATA_FLOW_INFO, expression, result.getDataFlowInfo());
}
return result;