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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart

Issue 2995553002: Implement type inference for asserts in constructor initializers. (Closed)
Patch Set: Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// This file declares a "shadow hierarchy" of concrete classes which extend 5 /// This file declares a "shadow hierarchy" of concrete classes which extend
6 /// the kernel class hierarchy, adding methods and fields needed by the 6 /// the kernel class hierarchy, adding methods and fields needed by the
7 /// BodyBuilder. 7 /// BodyBuilder.
8 /// 8 ///
9 /// Instances of these classes may be created using the factory methods in 9 /// Instances of these classes may be created using the factory methods in
10 /// `ast_factory.dart`. 10 /// `ast_factory.dart`.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { 83 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) {
84 typeNeeded = 84 typeNeeded =
85 inferrer.listener.asExpressionEnter(this, typeContext) || typeNeeded; 85 inferrer.listener.asExpressionEnter(this, typeContext) || typeNeeded;
86 inferrer.inferExpression(operand, null, false); 86 inferrer.inferExpression(operand, null, false);
87 var inferredType = typeNeeded ? type : null; 87 var inferredType = typeNeeded ? type : null;
88 inferrer.listener.asExpressionExit(this, inferredType); 88 inferrer.listener.asExpressionExit(this, inferredType);
89 return inferredType; 89 return inferredType;
90 } 90 }
91 } 91 }
92 92
93 /// Concrete shadow object representing an assert initializer in kernel form.
94 class KernelAssertInitializer extends LocalInitializer
95 implements KernelInitializer {
96 /// The assert statement performing the check
97 AssertStatement _statement;
98
99 KernelAssertInitializer(VariableDeclaration variable, this._statement)
100 : super(variable);
101
102 @override
103 void _inferInitializer(KernelTypeInferrer inferrer) {
104 inferrer.listener.assertInitializerEnter(this);
105 inferrer.inferStatement(_statement);
106 inferrer.listener.assertInitializerExit(this);
107 }
108 }
109
93 /// Concrete shadow object representing an assertion statement in kernel form. 110 /// Concrete shadow object representing an assertion statement in kernel form.
94 class KernelAssertStatement extends AssertStatement implements KernelStatement { 111 class KernelAssertStatement extends AssertStatement implements KernelStatement {
95 KernelAssertStatement(Expression condition, 112 KernelAssertStatement(Expression condition,
96 {Expression message, int conditionStartOffset, int conditionEndOffset}) 113 {Expression message, int conditionStartOffset, int conditionEndOffset})
97 : super(condition, 114 : super(condition,
98 message: message, 115 message: message,
99 conditionStartOffset: conditionStartOffset, 116 conditionStartOffset: conditionStartOffset,
100 conditionEndOffset: conditionEndOffset); 117 conditionEndOffset: conditionEndOffset);
101 118
102 @override 119 @override
(...skipping 2341 matching lines...) Expand 10 before | Expand all | Expand 10 after
2444 accept(v) => unsupported("accept", -1, null); 2461 accept(v) => unsupported("accept", -1, null);
2445 2462
2446 accept1(v, arg) => unsupported("accept1", -1, null); 2463 accept1(v, arg) => unsupported("accept1", -1, null);
2447 2464
2448 getStaticType(types) => unsupported("getStaticType", -1, null); 2465 getStaticType(types) => unsupported("getStaticType", -1, null);
2449 2466
2450 transformChildren(v) => unsupported("transformChildren", -1, null); 2467 transformChildren(v) => unsupported("transformChildren", -1, null);
2451 2468
2452 visitChildren(v) => unsupported("visitChildren", -1, null); 2469 visitChildren(v) => unsupported("visitChildren", -1, null);
2453 } 2470 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698