Chromium Code Reviews| 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 ddc.src.checker.checker; | 5 library ddc.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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 366 } | 366 } |
| 367 node.visitChildren(this); | 367 node.visitChildren(this); |
| 368 } | 368 } |
| 369 | 369 |
| 370 /// Check constructor declaration to ensure correct super call placement. | 370 /// Check constructor declaration to ensure correct super call placement. |
| 371 @override | 371 @override |
| 372 visitConstructorDeclaration(ConstructorDeclaration node) { | 372 visitConstructorDeclaration(ConstructorDeclaration node) { |
| 373 node.visitChildren(this); | 373 node.visitChildren(this); |
| 374 | 374 |
| 375 final init = node.initializers; | 375 final init = node.initializers; |
| 376 for (int i = 0, last = init.length - 1; i < last; i++) { | 376 for (int i = 0, last = init.length - 1; i <= last; i++) { |
| 377 final node = init[i]; | 377 final node = init[i]; |
| 378 if (node is SuperConstructorInvocation) { | 378 if (i != last && node is SuperConstructorInvocation) { |
| 379 _recordMessage(new InvalidSuperInvocation(node)); | 379 _recordMessage(new InvalidSuperInvocation(node)); |
| 380 } else if (node is ConstructorFieldInitializer) { | |
| 381 var field = node.fieldName; | |
| 382 DartType staticType = _rules.elementType(field.staticElement); | |
| 383 node.expression = checkAssignment(node.expression, staticType); | |
| 380 } | 384 } |
|
Leaf
2015/02/26 22:00:16
A little surprising that this isn't in a separate
vsm
2015/02/26 23:55:47
Done.
| |
| 381 } | 385 } |
| 382 } | 386 } |
| 383 | 387 |
| 384 // Check invocations | 388 // Check invocations |
| 385 bool checkArgumentList(ArgumentList node, FunctionType type) { | 389 bool checkArgumentList(ArgumentList node, FunctionType type) { |
| 386 NodeList<Expression> list = node.arguments; | 390 NodeList<Expression> list = node.arguments; |
| 387 int len = list.length; | 391 int len = list.length; |
| 388 for (int i = 0; i < len; ++i) { | 392 for (int i = 0; i < len; ++i) { |
| 389 Expression arg = list[i]; | 393 Expression arg = list[i]; |
| 390 ParameterElement element = node.getStaticParameterElementFor(arg); | 394 ParameterElement element = node.getStaticParameterElementFor(arg); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 670 void _recordDynamicInvoke(AstNode node) { | 674 void _recordDynamicInvoke(AstNode node) { |
| 671 _reporter.log(new DynamicInvoke(_rules, node)); | 675 _reporter.log(new DynamicInvoke(_rules, node)); |
| 672 } | 676 } |
| 673 | 677 |
| 674 void _recordMessage(StaticInfo info) { | 678 void _recordMessage(StaticInfo info) { |
| 675 if (info == null) return; | 679 if (info == null) return; |
| 676 if (info.level >= logger.Level.SEVERE) _failure = true; | 680 if (info.level >= logger.Level.SEVERE) _failure = true; |
| 677 _reporter.log(info); | 681 _reporter.log(info); |
| 678 } | 682 } |
| 679 } | 683 } |
| OLD | NEW |