Skip to content

Commit

Permalink
fixes #15, strong mode errors and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
John Messerly committed Oct 1, 2015
1 parent fb4313d commit 390612b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/src/loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class Loader {
throw new YamlException("Invalid tag for sequence.", firstEvent.span);
}

var children = [];
var children = <YamlNode>[];
var node = new YamlList.internal(
children, firstEvent.span, firstEvent.style);
_registerAnchor(firstEvent.anchor, node);
Expand Down
3 changes: 2 additions & 1 deletion lib/src/scanner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ class Scanner {
var token = _tokens.last;
if (token.type == TokenType.FLOW_SEQUENCE_END ||
token.type == TokenType.FLOW_MAPPING_END ||
(token.type == TokenType.SCALAR && token.style.isQuoted)) {
(token.type == TokenType.SCALAR &&
(token as ScalarToken).style.isQuoted)) {
_fetchValue();
return;
}
Expand Down
8 changes: 5 additions & 3 deletions lib/yaml.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,17 @@ YamlDocument loadYamlDocument(String yaml, {sourceUrl}) {
YamlList loadYamlStream(String yaml, {sourceUrl}) {
var loader = new Loader(yaml, sourceUrl: sourceUrl);

var documents = [];
var documents = <YamlDocument>[];
var document = loader.load();
while (document != null) {
documents.add(document);
document = loader.load();
}

// TODO(jmesserly): the type on the `document` parameter is a workaround for:
// https://github.com/dart-lang/dev_compiler/issues/203
return new YamlList.internal(
documents.map((document) => document.contents).toList(),
documents.map((YamlDocument document) => document.contents).toList(),
loader.span,
CollectionStyle.ANY);
}
Expand All @@ -101,7 +103,7 @@ YamlList loadYamlStream(String yaml, {sourceUrl}) {
List<YamlDocument> loadYamlDocuments(String yaml, {sourceUrl}) {
var loader = new Loader(yaml, sourceUrl: sourceUrl);

var documents = [];
var documents = <YamlDocument>[];
var document = loader.load();
while (document != null) {
documents.add(document);
Expand Down

0 comments on commit 390612b

Please sign in to comment.