Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1929)

Unified Diff: pkg/front_end/lib/src/fasta/source/outline_builder.dart

Issue 2675603002: Reduce strong mode errors and warnings (Closed)
Patch Set: comments & cleanup Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/src/fasta/source/outline_builder.dart
diff --git a/pkg/front_end/lib/src/fasta/source/outline_builder.dart b/pkg/front_end/lib/src/fasta/source/outline_builder.dart
index 4549589d4596b52b14b563dabd06e9a3170f4987..b1dc83ae6763d9e9a55c35b4dee83e2e7a5ba46c 100644
--- a/pkg/front_end/lib/src/fasta/source/outline_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/outline_builder.dart
@@ -370,7 +370,20 @@ class OutlineBuilder extends UnhandledListener {
if (formals != null && formals.isNotEmpty) {
var last = formals.last;
if (last is List) {
- var newList =
+ // TODO(sigmund): change `List newList` back to `var`.
+ //
+ // Note: in strong-mode the two `setRange` statements below fail
+ // dynamically because `formals` and `last` are not
+ // Iterable<FormalParameterBuilder>.
+ // A way to fix this without coping or iterating over
+ // the list of formals would be to split the optional arguments as a
+ // separate value on the parsing stack, then simply concatenate them:
+ //
+ // List<FormalParameterBuilder> optionalFormals = pop();
+ // List<FormalParameterBuilder> requiredFormals = popList(count);
+ //
+ // The resulting code might also be easier to follow.
+ 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
new List<FormalParameterBuilder>(formals.length - 1 + last.length);
newList.setRange(0, formals.length - 1, formals);
newList.setRange(formals.length - 1, newList.length, last);

Powered by Google App Engine
This is Rietveld 408576698