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

Side by Side Diff: pkg/compiler/lib/src/typechecker.dart

Issue 1342213003: Add optional message to assert in Dart2js - continued (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Add dart2js test Created 5 years, 3 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 library dart2js.typechecker; 5 library dart2js.typechecker;
6 6
7 import 'common/names.dart' show 7 import 'common/names.dart' show
8 Identifiers; 8 Identifiers;
9 import 'common/tasks.dart' show 9 import 'common/tasks.dart' show
10 CompilerTask; 10 CompilerTask;
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 void pushCascadeType(DartType type) { 607 void pushCascadeType(DartType type) {
608 cascadeTypes = cascadeTypes.prepend(type); 608 cascadeTypes = cascadeTypes.prepend(type);
609 } 609 }
610 610
611 DartType popCascadeType() { 611 DartType popCascadeType() {
612 DartType type = cascadeTypes.head; 612 DartType type = cascadeTypes.head;
613 cascadeTypes = cascadeTypes.tail; 613 cascadeTypes = cascadeTypes.tail;
614 return type; 614 return type;
615 } 615 }
616 616
617 DartType visitAssert(Assert node) {
618 analyze(node.condition);
619 if (node.hasMessage) analyze(node.message);
620 return const StatementType();
621 }
622
617 DartType visitBlock(Block node) { 623 DartType visitBlock(Block node) {
618 return analyze(node.statements); 624 return analyze(node.statements);
619 } 625 }
620 626
621 DartType visitCascade(Cascade node) { 627 DartType visitCascade(Cascade node) {
622 analyze(node.expression); 628 analyze(node.expression);
623 return popCascadeType(); 629 return popCascadeType();
624 } 630 }
625 631
626 DartType visitCascadeReceiver(CascadeReceiver node) { 632 DartType visitCascadeReceiver(CascadeReceiver node) {
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 // This should be the case but we double-check. 1164 // This should be the case but we double-check.
1159 // TODO(johnniwinther): Ensure that we don't suggest malbounded types. 1165 // TODO(johnniwinther): Ensure that we don't suggest malbounded types.
1160 return shownTypeGeneric; 1166 return shownTypeGeneric;
1161 } 1167 }
1162 } 1168 }
1163 return null; 1169 return null;
1164 1170
1165 } 1171 }
1166 1172
1167 DartType visitSend(Send node) { 1173 DartType visitSend(Send node) {
1168 if (elements.isAssert(node)) {
1169 return analyzeInvocation(node, const AssertAccess());
1170 }
1171
1172 Element element = elements[node]; 1174 Element element = elements[node];
1173 1175
1174 if (element != null && element.isConstructor) { 1176 if (element != null && element.isConstructor) {
1175 DartType receiverType; 1177 DartType receiverType;
1176 if (node.receiver != null) { 1178 if (node.receiver != null) {
1177 receiverType = analyze(node.receiver); 1179 receiverType = analyze(node.receiver);
1178 } else if (node.selector.isSuper()) { 1180 } else if (node.selector.isSuper()) {
1179 // TODO(johnniwinther): Lookup super-member in class members. 1181 // TODO(johnniwinther): Lookup super-member in class members.
1180 receiverType = superType; 1182 receiverType = superType;
1181 } else { 1183 } else {
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
1974 1976
1975 visitTypedef(Typedef node) { 1977 visitTypedef(Typedef node) {
1976 // Do not typecheck [Typedef] nodes. 1978 // Do not typecheck [Typedef] nodes.
1977 } 1979 }
1978 1980
1979 visitNode(Node node) { 1981 visitNode(Node node) {
1980 compiler.internalError(node, 1982 compiler.internalError(node,
1981 'Unexpected node ${node.getObjectDescription()} in the type checker.'); 1983 'Unexpected node ${node.getObjectDescription()} in the type checker.');
1982 } 1984 }
1983 } 1985 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698