OLD | NEW |
---|---|
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 dev_compiler.src.checker.checker; | 5 library dev_compiler.src.checker.checker; |
6 | 6 |
7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
9 import 'package:analyzer/src/generated/element.dart'; | 9 import 'package:analyzer/src/generated/element.dart'; |
10 import 'package:analyzer/src/generated/scanner.dart' show Token, TokenType; | 10 import 'package:analyzer/src/generated/scanner.dart' show Token, TokenType; |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 final node = init[i]; | 368 final node = init[i]; |
369 if (node is SuperConstructorInvocation) { | 369 if (node is SuperConstructorInvocation) { |
370 _recordMessage(new InvalidSuperInvocation(node)); | 370 _recordMessage(new InvalidSuperInvocation(node)); |
371 } | 371 } |
372 } | 372 } |
373 } | 373 } |
374 | 374 |
375 @override | 375 @override |
376 void visitConstructorFieldInitializer(ConstructorFieldInitializer node) { | 376 void visitConstructorFieldInitializer(ConstructorFieldInitializer node) { |
377 var field = node.fieldName; | 377 var field = node.fieldName; |
378 DartType staticType = rules.elementType(field.staticElement); | 378 var element = field.staticElement; |
vsm
2015/08/25 21:47:26
FWIW, I recently changed rules.elementType to retu
Jennifer Messerly
2015/08/25 22:13:11
Nice! reverted this
| |
379 DartType staticType = element != null | |
380 ? rules.elementType(element) | |
381 : rules.provider.dynamicType; | |
379 checkAssignment(node.expression, staticType); | 382 checkAssignment(node.expression, staticType); |
380 node.visitChildren(this); | 383 node.visitChildren(this); |
381 } | 384 } |
382 | 385 |
383 @override | 386 @override |
384 void visitForEachStatement(ForEachStatement node) { | 387 void visitForEachStatement(ForEachStatement node) { |
385 // Check that the expression is an Iterable. | 388 // Check that the expression is an Iterable. |
386 var expr = node.iterable; | 389 var expr = node.iterable; |
387 var iterableType = node.awaitKeyword != null | 390 var iterableType = node.awaitKeyword != null |
388 ? rules.provider.streamType | 391 ? rules.provider.streamType |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
769 } else { | 772 } else { |
770 // Non-method operator. | 773 // Non-method operator. |
771 switch (op.type) { | 774 switch (op.type) { |
772 case TokenType.AMPERSAND_AMPERSAND: | 775 case TokenType.AMPERSAND_AMPERSAND: |
773 case TokenType.BAR_BAR: | 776 case TokenType.BAR_BAR: |
774 checkBoolean(node.leftOperand); | 777 checkBoolean(node.leftOperand); |
775 checkBoolean(node.rightOperand); | 778 checkBoolean(node.rightOperand); |
776 break; | 779 break; |
777 case TokenType.BANG_EQ: | 780 case TokenType.BANG_EQ: |
778 break; | 781 break; |
782 case TokenType.QUESTION_QUESTION: | |
783 break; | |
779 default: | 784 default: |
780 assert(false); | 785 assert(false); |
781 } | 786 } |
782 } | 787 } |
783 node.visitChildren(this); | 788 node.visitChildren(this); |
784 } | 789 } |
785 | 790 |
786 @override | 791 @override |
787 void visitConditionalExpression(ConditionalExpression node) { | 792 void visitConditionalExpression(ConditionalExpression node) { |
788 checkBoolean(node.condition); | 793 checkBoolean(node.condition); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
918 if (info is CoercionInfo) { | 923 if (info is CoercionInfo) { |
919 // TODO(jmesserly): if we're run again on the same AST, we'll produce the | 924 // TODO(jmesserly): if we're run again on the same AST, we'll produce the |
920 // same annotations. This should be harmless. This might go away once | 925 // same annotations. This should be harmless. This might go away once |
921 // CodeChecker is integrated better with analyzer, as it will know that | 926 // CodeChecker is integrated better with analyzer, as it will know that |
922 // checking has already been performed. | 927 // checking has already been performed. |
923 // assert(CoercionInfo.get(info.node) == null); | 928 // assert(CoercionInfo.get(info.node) == null); |
924 CoercionInfo.set(info.node, info); | 929 CoercionInfo.set(info.node, info); |
925 } | 930 } |
926 } | 931 } |
927 } | 932 } |
OLD | NEW |