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

Unified Diff: lib/src/checker/resolver.dart

Issue 997143003: Fix for conditional expressions (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | lib/src/codegen/js_codegen.dart » ('j') | lib/src/codegen/js_codegen.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/checker/resolver.dart
diff --git a/lib/src/checker/resolver.dart b/lib/src/checker/resolver.dart
index c31a1d72abf741d2bae2f38824996938a2de116d..0c3956a5e2b82006b0ec6469351911d1523bc2ae 100644
--- a/lib/src/checker/resolver.dart
+++ b/lib/src/checker/resolver.dart
@@ -396,6 +396,24 @@ class RestrictedStaticTypeAnalyzer extends StaticTypeAnalyzer {
}
}
+ @override
+ visitConditionalExpression(ConditionalExpression node) {
+ // TODO(vsm): This seems to be a bug in the analyzer. The static type of
+ // a conditional should be the LUB of the then and else expressions.
+ // The analyzer appears to compute dynamic when one or the other is the
+ // null literal.
vsm 2015/03/16 13:20:54 I think the better fix would be in getLeastUpperBo
vsm 2015/03/16 13:44:58 Bug filed at: https://code.google.com/p/dart/issue
+ super.visitConditionalExpression(node);
+ if (node.staticType.isDynamic) {
+ var thenExpr = node.thenExpression;
+ var elseExpr = node.elseExpression;
+ if (thenExpr.staticType.isBottom) {
+ node.staticType = elseExpr.staticType;
+ } else if (elseExpr.staticType.isBottom) {
+ node.staticType = thenExpr.staticType;
+ }
+ }
+ }
+
// Review note: no longer need to override visitFunctionExpression, this is
// handled by the analyzer internally.
// TODO(vsm): in visitbinaryExpression: check computeStaticReturnType result?
« no previous file with comments | « no previous file | lib/src/codegen/js_codegen.dart » ('j') | lib/src/codegen/js_codegen.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698