Index: pkg/analyzer/lib/src/generated/resolver.dart |
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart |
index afa7ccec98ee9c48746663cc1c1a9893c0b0b541..7b9571b61f4e50aa1ccb027b5389d39b68a8f6ee 100644 |
--- a/pkg/analyzer/lib/src/generated/resolver.dart |
+++ b/pkg/analyzer/lib/src/generated/resolver.dart |
@@ -6062,9 +6062,18 @@ class ResolverVisitor extends ScopedVisitor { |
// of the binary operator for other cases. |
if (operatorType == TokenType.QUESTION_QUESTION) { |
InferenceContext.setTypeFromNode(leftOperand, node); |
- InferenceContext.setTypeFromNode(rightOperand, node); |
} |
leftOperand?.accept(this); |
+ if (operatorType == TokenType.QUESTION_QUESTION) { |
+ // Set the right side, either from the context, or using the information |
+ // from the left side if it is more precise. |
+ DartType contextType = InferenceContext.getType(node); |
+ DartType leftType = leftOperand?.staticType; |
+ if (contextType == null || contextType.isDynamic) { |
+ contextType = leftType; |
+ } |
+ InferenceContext.setType(rightOperand, contextType); |
+ } |
rightOperand?.accept(this); |
} |
node.accept(elementResolver); |
@@ -6947,6 +6956,8 @@ class ResolverVisitor extends ScopedVisitor { |
@override |
visitVariableDeclarationList(VariableDeclarationList node) { |
for (VariableDeclaration decl in node.variables) { |
+ // TODO(jmesserly): this sets the type even when it's implicitly dynamic. |
+ // Do we need to do thiat? |
Leaf
2016/08/04 22:26:44
Might even be worth filtering out dynamic in setTy
Jennifer Messerly
2016/08/04 22:57:49
Oh! good idea. I'll move the TODO and do it in a f
|
InferenceContext.setType(decl, decl.element?.type); |
} |
super.visitVariableDeclarationList(node); |