Remove Dart 2 errors in package:js_ast

Change-Id: I1684a662bb777e2175cb0f1a6590136ab3ba5cc2
Reviewed-on: https://dart-review.googlesource.com/48580
Reviewed-by: Stephen Adams <sra@google.com>
This commit is contained in:
Johnni Winther 2018-03-30 11:21:21 +00:00
parent a6a2152482
commit 8504808ce3
4 changed files with 18 additions and 14 deletions

View file

@ -466,7 +466,7 @@ class JsBuilder {
}
Iterable<Literal> joinLiterals(Iterable<Literal> list, Literal separator) {
return new _InterleaveIterable(list, separator);
return new _InterleaveIterable<Literal>(list, separator);
}
LiteralString quoteName(Name name, {allowNull: false}) {
@ -1574,9 +1574,9 @@ class MiniJsParser {
}
}
class _InterleaveIterator implements Iterator<Node> {
Iterator<Node> source;
Node separator;
class _InterleaveIterator<T extends Node> implements Iterator<T> {
Iterator<T> source;
T separator;
bool isNextSeparator = false;
bool isInitialized = false;
@ -1594,19 +1594,19 @@ class _InterleaveIterator implements Iterator<Node> {
}
}
Node get current {
T get current {
if (isNextSeparator) return separator;
return source.current;
}
}
class _InterleaveIterable extends IterableBase {
Iterable<Node> source;
Node separator;
class _InterleaveIterable<T extends Node> extends IterableBase<T> {
Iterable<T> source;
T separator;
_InterleaveIterable(this.source, this.separator);
Iterator<Node> get iterator {
return new _InterleaveIterator(source.iterator, separator);
Iterator<T> get iterator {
return new _InterleaveIterator<T>(source.iterator, separator);
}
}

View file

@ -979,6 +979,8 @@ abstract class Name extends Literal
R accept1<R, A>(NodeVisitor1<R, A> visitor, A arg) =>
visitor.visitName(this, arg);
Name _clone();
/// Returns a unique [key] for this name.
///
/// The key is unrelated to the actual name and is not intended for human

View file

@ -1297,7 +1297,7 @@ class DanglingElseVisitor extends BaseVisitor<bool> {
bool visitProgram(Program node) => false;
bool visitNode(Statement node) {
bool visitNode(Node node) {
context.error("Forgot node: $node");
return null;
}

View file

@ -130,7 +130,7 @@ class Template {
* trees. [arguments] is a List for positional templates, or Map for
* named templates.
*/
typedef Node Instantiator(var arguments);
typedef /*Node|Iterable<Node>*/ Instantiator(var arguments);
/**
* InstantiatorGeneratorVisitor compiles a template. This class compiles a tree
@ -300,7 +300,8 @@ class InstantiatorGeneratorVisitor implements NodeVisitor<Instantiator> {
}
Instantiator visitProgram(Program node) {
List instantiators = node.body.map(visitSplayableStatement).toList();
List<Instantiator> instantiators =
node.body.map(visitSplayableStatement).toList();
return (arguments) {
List<Statement> statements = <Statement>[];
void add(node) {
@ -320,7 +321,8 @@ class InstantiatorGeneratorVisitor implements NodeVisitor<Instantiator> {
}
Instantiator visitBlock(Block node) {
List instantiators = node.statements.map(visitSplayableStatement).toList();
List<Instantiator> instantiators =
node.statements.map(visitSplayableStatement).toList();
return (arguments) {
List<Statement> statements = <Statement>[];
void add(node) {