Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 fasta.outline_builder; | 5 library fasta.outline_builder; |
| 6 | 6 |
| 7 import 'package:kernel/ast.dart' show | 7 import 'package:kernel/ast.dart' show |
| 8 AsyncMarker, | 8 AsyncMarker, |
| 9 ProcedureKind; | 9 ProcedureKind; |
| 10 | 10 |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 363 push(parameters); | 363 push(parameters); |
| 364 } | 364 } |
| 365 | 365 |
| 366 @override | 366 @override |
| 367 void endFormalParameters(int count, Token beginToken, Token endToken) { | 367 void endFormalParameters(int count, Token beginToken, Token endToken) { |
| 368 debugEvent("FormalParameters"); | 368 debugEvent("FormalParameters"); |
| 369 List formals = popList(count); | 369 List formals = popList(count); |
| 370 if (formals != null && formals.isNotEmpty) { | 370 if (formals != null && formals.isNotEmpty) { |
| 371 var last = formals.last; | 371 var last = formals.last; |
| 372 if (last is List) { | 372 if (last is List) { |
| 373 var newList = | 373 // TODO(sigmund): change `List newList` back to `var`. |
| 374 // | |
| 375 // Note: in strong-mode the two `setRange` statements below fail | |
| 376 // dynamically because `formals` and `last` are not | |
| 377 // Iterable<FormalParameterBuilder>. | |
| 378 // A way to fix this without coping or iterating over | |
| 379 // the list of formals would be to split the optional arguments as a | |
| 380 // separate value on the parsing stack, then simply concatenate them: | |
| 381 // | |
| 382 // List<FormalParameterBuilder> optionalFormals = pop(); | |
| 383 // List<FormalParameterBuilder> requiredFormals = popList(count); | |
| 384 // | |
| 385 // The resulting code might also be easier to follow. | |
| 386 List newList = | |
|
ahe
2017/02/07 11:03:08
You don't need to add this comment, just do this:
Siggi Cherem (dart-lang)
2017/02/07 21:59:26
Here too: `var` is inferred as `List<FormalParamet
| |
| 374 new List<FormalParameterBuilder>(formals.length - 1 + last.length); | 387 new List<FormalParameterBuilder>(formals.length - 1 + last.length); |
| 375 newList.setRange(0, formals.length - 1, formals); | 388 newList.setRange(0, formals.length - 1, formals); |
| 376 newList.setRange(formals.length - 1, newList.length, last); | 389 newList.setRange(formals.length - 1, newList.length, last); |
| 377 for (int i = 0; i < last.length; i++) { | 390 for (int i = 0; i < last.length; i++) { |
| 378 newList[i + formals.length - 1] = last[i]; | 391 newList[i + formals.length - 1] = last[i]; |
| 379 } | 392 } |
| 380 formals = newList; | 393 formals = newList; |
| 381 } | 394 } |
| 382 } | 395 } |
| 383 if (formals != null) { | 396 if (formals != null) { |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 551 Link<Token> handleMemberName(Link<Token> identifiers) { | 564 Link<Token> handleMemberName(Link<Token> identifiers) { |
| 552 if (!isDartLibrary || identifiers.isEmpty) return identifiers; | 565 if (!isDartLibrary || identifiers.isEmpty) return identifiers; |
| 553 return removeNativeClause(identifiers); | 566 return removeNativeClause(identifiers); |
| 554 } | 567 } |
| 555 | 568 |
| 556 @override | 569 @override |
| 557 void debugEvent(String name) { | 570 void debugEvent(String name) { |
| 558 // printEvent(name); | 571 // printEvent(name); |
| 559 } | 572 } |
| 560 } | 573 } |
| OLD | NEW |