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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 (node is SuperConstructorInvocation) { |
| 379 _recordMessage(new InvalidSuperInvocation(node)); | 379 _recordMessage(new InvalidSuperInvocation(node)); |
| 380 } | 380 } |
| 381 } | 381 } |
| 382 } | 382 } |
| 383 | 383 |
| 384 @override visitListLiteral(ListLiteral node) { | |
| 385 var type = _rules.provider.dynamicType; | |
| 386 if (node.typeArguments != null) { | |
| 387 var targs = node.typeArguments.arguments; | |
| 388 if (targs.length > 0) type = targs[0].type; | |
| 389 } | |
| 390 var elements = node.elements; | |
|
vsm
2015/02/25 20:52:28
You could lift this block into the nested if above
Leaf
2015/02/25 21:07:04
Yeah, had it that way, then changed it just on the
| |
| 391 for (int i = 0; i < elements.length; i++) { | |
| 392 elements[i] = checkArgument(elements[i], type); | |
|
vsm
2015/02/25 20:52:29
Are you already keeping track of whether we're in
Leaf
2015/02/25 21:07:04
I'm not checking for const currently. I considere
| |
| 393 } | |
| 394 super.visitListLiteral(node); | |
| 395 } | |
| 396 | |
| 397 @override visitMapLiteral(MapLiteral node) { | |
| 398 var ktype = _rules.provider.dynamicType; | |
| 399 var vtype = _rules.provider.dynamicType; | |
| 400 if (node.typeArguments != null) { | |
| 401 var targs = node.typeArguments.arguments; | |
| 402 if (targs.length > 0) ktype = targs[0].type; | |
| 403 if (targs.length > 1) vtype = targs[1].type; | |
| 404 } | |
| 405 var entries = node.entries; | |
|
vsm
2015/02/25 20:52:29
ditto
| |
| 406 for (int i = 0; i < entries.length; i++) { | |
| 407 var entry = entries[i]; | |
| 408 entry.key = checkArgument(entry.key, ktype); | |
| 409 entry.value = checkArgument(entry.value, vtype); | |
| 410 } | |
| 411 super.visitMapLiteral(node); | |
| 412 } | |
| 413 | |
| 384 // Check invocations | 414 // Check invocations |
| 385 bool checkArgumentList(ArgumentList node, FunctionType type) { | 415 bool checkArgumentList(ArgumentList node, FunctionType type) { |
| 386 NodeList<Expression> list = node.arguments; | 416 NodeList<Expression> list = node.arguments; |
| 387 int len = list.length; | 417 int len = list.length; |
| 388 for (int i = 0; i < len; ++i) { | 418 for (int i = 0; i < len; ++i) { |
| 389 Expression arg = list[i]; | 419 Expression arg = list[i]; |
| 390 ParameterElement element = node.getStaticParameterElementFor(arg); | 420 ParameterElement element = node.getStaticParameterElementFor(arg); |
| 391 if (element == null) { | 421 if (element == null) { |
| 392 if (type.parameters.length < len) { | 422 if (type.parameters.length < len) { |
| 393 // We found an argument mismatch, the analyzer will report this too, | 423 // We found an argument mismatch, the analyzer will report this too, |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 670 void _recordDynamicInvoke(AstNode node) { | 700 void _recordDynamicInvoke(AstNode node) { |
| 671 _reporter.log(new DynamicInvoke(_rules, node)); | 701 _reporter.log(new DynamicInvoke(_rules, node)); |
| 672 } | 702 } |
| 673 | 703 |
| 674 void _recordMessage(StaticInfo info) { | 704 void _recordMessage(StaticInfo info) { |
| 675 if (info == null) return; | 705 if (info == null) return; |
| 676 if (info.level >= logger.Level.SEVERE) _failure = true; | 706 if (info.level >= logger.Level.SEVERE) _failure = true; |
| 677 _reporter.log(info); | 707 _reporter.log(info); |
| 678 } | 708 } |
| 679 } | 709 } |
| OLD | NEW |