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

Unified Diff: lib/ast.dart

Issue 2465263002: Always store the type of a conditional expression on the node. (Closed)
Patch Set: Update test expectation Created 4 years, 1 month 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 | « lib/analyzer/ast_from_analyzer.dart ('k') | lib/frontend/accessors.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/ast.dart
diff --git a/lib/ast.dart b/lib/ast.dart
index dc9cb6d746dcd22c33fdaef7ddef60f81a46a564..788f53ec0913c73c55bed72f18009c65a0f84ef6 100644
--- a/lib/ast.dart
+++ b/lib/ast.dart
@@ -1978,28 +1978,17 @@ class ConditionalExpression extends Expression {
Expression then;
Expression otherwise;
- /// The static type of the expression, or `null` if the type should be derived
- /// from [then] and [otherwise] using a very simple upper bound computation.
- ///
- /// If one of the arms is a null literal, the static type of the other
- /// arm will be used.
+ /// The static type of the expression. Should not be `null`.
DartType staticType;
ConditionalExpression(this.condition, this.then, this.otherwise,
- [this.staticType]) {
+ this.staticType) {
condition?.parent = this;
then?.parent = this;
otherwise?.parent = this;
}
- DartType getStaticType(TypeEnvironment types) {
- if (staticType != null) return staticType;
- var left = then.getStaticType(types);
- var right = otherwise.getStaticType(types);
- if (left is BottomType) return right;
- if (right is BottomType) return left;
- return const DynamicType();
- }
+ DartType getStaticType(TypeEnvironment types) => staticType;
accept(ExpressionVisitor v) => v.visitConditionalExpression(this);
« no previous file with comments | « lib/analyzer/ast_from_analyzer.dart ('k') | lib/frontend/accessors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698