Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Unified Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 2217693003: fix #26552, improve null coalescing inference (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);

Powered by Google App Engine
This is Rietveld 408576698