Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit 390612b

Browse files
author
John Messerly
committed
fixes #15, strong mode errors and warnings
1 parent fb4313d commit 390612b

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

lib/src/loader.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class Loader {
127127
throw new YamlException("Invalid tag for sequence.", firstEvent.span);
128128
}
129129

130-
var children = [];
130+
var children = <YamlNode>[];
131131
var node = new YamlList.internal(
132132
children, firstEvent.span, firstEvent.style);
133133
_registerAnchor(firstEvent.anchor, node);

lib/src/scanner.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,8 @@ class Scanner {
443443
var token = _tokens.last;
444444
if (token.type == TokenType.FLOW_SEQUENCE_END ||
445445
token.type == TokenType.FLOW_MAPPING_END ||
446-
(token.type == TokenType.SCALAR && token.style.isQuoted)) {
446+
(token.type == TokenType.SCALAR &&
447+
(token as ScalarToken).style.isQuoted)) {
447448
_fetchValue();
448449
return;
449450
}

lib/yaml.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,17 @@ YamlDocument loadYamlDocument(String yaml, {sourceUrl}) {
8181
YamlList loadYamlStream(String yaml, {sourceUrl}) {
8282
var loader = new Loader(yaml, sourceUrl: sourceUrl);
8383

84-
var documents = [];
84+
var documents = <YamlDocument>[];
8585
var document = loader.load();
8686
while (document != null) {
8787
documents.add(document);
8888
document = loader.load();
8989
}
9090

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

104-
var documents = [];
106+
var documents = <YamlDocument>[];
105107
var document = loader.load();
106108
while (document != null) {
107109
documents.add(document);

0 commit comments

Comments
 (0)