OLD | NEW |
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/tasks.dart' show | 7 import 'common/tasks.dart' show |
8 CompilerTask; | 8 CompilerTask; |
9 import 'compiler.dart' show | 9 import 'compiler.dart' show |
10 Compiler, | 10 Compiler, |
(...skipping 585 matching lines...) Loading... |
596 void pushCascadeType(DartType type) { | 596 void pushCascadeType(DartType type) { |
597 cascadeTypes = cascadeTypes.prepend(type); | 597 cascadeTypes = cascadeTypes.prepend(type); |
598 } | 598 } |
599 | 599 |
600 DartType popCascadeType() { | 600 DartType popCascadeType() { |
601 DartType type = cascadeTypes.head; | 601 DartType type = cascadeTypes.head; |
602 cascadeTypes = cascadeTypes.tail; | 602 cascadeTypes = cascadeTypes.tail; |
603 return type; | 603 return type; |
604 } | 604 } |
605 | 605 |
| 606 DartType visitAssert(Assert node) { |
| 607 analyze(node.condition); |
| 608 if (node.hasMessage) analyze(node.message); |
| 609 return const StatementType(); |
| 610 } |
| 611 |
606 DartType visitBlock(Block node) { | 612 DartType visitBlock(Block node) { |
607 return analyze(node.statements); | 613 return analyze(node.statements); |
608 } | 614 } |
609 | 615 |
610 DartType visitCascade(Cascade node) { | 616 DartType visitCascade(Cascade node) { |
611 analyze(node.expression); | 617 analyze(node.expression); |
612 return popCascadeType(); | 618 return popCascadeType(); |
613 } | 619 } |
614 | 620 |
615 DartType visitCascadeReceiver(CascadeReceiver node) { | 621 DartType visitCascadeReceiver(CascadeReceiver node) { |
(...skipping 548 matching lines...) Loading... |
1164 // This should be the case but we double-check. | 1170 // This should be the case but we double-check. |
1165 // TODO(johnniwinther): Ensure that we don't suggest malbounded types. | 1171 // TODO(johnniwinther): Ensure that we don't suggest malbounded types. |
1166 return shownTypeGeneric; | 1172 return shownTypeGeneric; |
1167 } | 1173 } |
1168 } | 1174 } |
1169 return null; | 1175 return null; |
1170 | 1176 |
1171 } | 1177 } |
1172 | 1178 |
1173 DartType visitSend(Send node) { | 1179 DartType visitSend(Send node) { |
1174 if (elements.isAssert(node)) { | |
1175 return analyzeInvocation(node, const AssertAccess()); | |
1176 } | |
1177 | |
1178 Element element = elements[node]; | 1180 Element element = elements[node]; |
1179 | 1181 |
1180 if (element != null && element.isConstructor) { | 1182 if (element != null && element.isConstructor) { |
1181 DartType receiverType; | 1183 DartType receiverType; |
1182 if (node.receiver != null) { | 1184 if (node.receiver != null) { |
1183 receiverType = analyze(node.receiver); | 1185 receiverType = analyze(node.receiver); |
1184 } else if (node.selector.isSuper()) { | 1186 } else if (node.selector.isSuper()) { |
1185 // TODO(johnniwinther): Lookup super-member in class members. | 1187 // TODO(johnniwinther): Lookup super-member in class members. |
1186 receiverType = superType; | 1188 receiverType = superType; |
1187 } else { | 1189 } else { |
(...skipping 739 matching lines...) Loading... |
1927 | 1929 |
1928 visitTypedef(Typedef node) { | 1930 visitTypedef(Typedef node) { |
1929 // Do not typecheck [Typedef] nodes. | 1931 // Do not typecheck [Typedef] nodes. |
1930 } | 1932 } |
1931 | 1933 |
1932 visitNode(Node node) { | 1934 visitNode(Node node) { |
1933 compiler.internalError(node, | 1935 compiler.internalError(node, |
1934 'Unexpected node ${node.getObjectDescription()} in the type checker.'); | 1936 'Unexpected node ${node.getObjectDescription()} in the type checker.'); |
1935 } | 1937 } |
1936 } | 1938 } |
OLD | NEW |