Skip to content

Commit 182f1f5

Browse files
committed
make strong-mode happy
1 parent 0dc9691 commit 182f1f5

File tree

8 files changed

+31
-22
lines changed

8 files changed

+31
-22
lines changed

.analysis_options

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
analyzer:
2-
# disabling strong-mode until all errors and warnings are resolved
3-
# strong-mode: true
2+
strong-mode: true

lib/src/asset/cache.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ class CachedAssetReader extends AssetReader {
6262
Future<bool> hasInput(AssetId id) {
6363
try {
6464
if (_cache.contains(id)) return new Future.value(true);
65-
6665
return _pendingHasInputChecks.putIfAbsent(id, () async {
6766
try {
68-
return await _reader.hasInput(id);
67+
return _reader.hasInput(id);
6968
} finally {
69+
// Make sure we always remove the pending check
7070
_pendingHasInputChecks.remove(id);
7171
}
7272
});

lib/src/asset_graph/node.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class GeneratedAssetNode extends AssetNode {
5656
factory GeneratedAssetNode.deserialize(List serialized) {
5757
var node = new GeneratedAssetNode(new AssetId.deserialize(serialized[2]),
5858
false, serialized[3], new AssetId.deserialize(serialized[0]));
59-
node.outputs.addAll(serialized[1]
59+
node.outputs.addAll((serialized[1] as Iterable)
6060
.map((serializedOutput) => new AssetId.deserialize(serializedOutput)));
6161
return node;
6262
}

lib/src/generate/build_impl.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ class BuildImpl {
224224
/// Collect updates to the graph based on any changed assets.
225225
var updates = <AssetId, ChangeType>{};
226226
await Future.wait(_assetGraph.allNodes
227-
.where((node) => node is! GeneratedAssetNode || node.wasOutput)
227+
.where((node) =>
228+
node is! GeneratedAssetNode ||
229+
(node as GeneratedAssetNode).wasOutput)
228230
.map((node) async {
229231
var exists = await _reader.hasInput(node.id);
230232
if (!exists) {
@@ -297,7 +299,7 @@ class BuildImpl {
297299
.where((node) => node is GeneratedAssetNode)
298300
.map((node) async {
299301
_inputsByPackage[node.id.package]?.remove(node.id);
300-
if (node.needsUpdate) {
302+
if ((node as GeneratedAssetNode).needsUpdate) {
301303
await _writer.delete(node.id);
302304
}
303305
}));
@@ -353,7 +355,7 @@ class BuildImpl {
353355
switch (input.toLowerCase()) {
354356
case 'y':
355357
stdout.writeln('Deleting files...');
356-
await Future.wait(conflictingOutputs.map((output) {
358+
await Future.wait(conflictingOutputs.map/*<Future>*/((output) {
357359
_inputsByPackage[output.package]?.remove(output);
358360
return _writer.delete(output);
359361
}));

test/analyzer/resolver_test.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ main() {
4646
return validateResolver(
4747
inputs: {'a|web/main.dart': ' main() {}',},
4848
validator: (resolver) {
49-
var source =
50-
resolver.resolver.sources[toBarbackAssetId(entryPoint)];
49+
var source = (resolver.resolver as dynamic).sources[
50+
toBarbackAssetId(entryPoint)];
5151
expect(source.modificationStamp, 1);
5252

5353
var lib = resolver.getLibrary(entryPoint);
@@ -62,8 +62,8 @@ main() {
6262
} ''',
6363
},
6464
validator: (resolver) {
65-
var source =
66-
resolver.resolver.sources[toBarbackAssetId(entryPoint)];
65+
var source = (resolver.resolver as dynamic).sources[
66+
toBarbackAssetId(entryPoint)];
6767
expect(source.modificationStamp, 2);
6868

6969
var lib = resolver.getLibrary(entryPoint);
@@ -303,7 +303,7 @@ main() {
303303
expect(uri.toString(), 'package:a/a.dart');
304304

305305
// Make sure that we haven't leaked any sources.
306-
expect(resolver.resolver.sources.length, 2);
306+
expect((resolver.resolver as dynamic).sources.length, 2);
307307
});
308308
});
309309
});

test/asset/file_based_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ main() {
5757
});
5858

5959
test('can list files based on simple InputSets', () async {
60-
var inputSets = [
60+
var inputSets = <InputSet>[
6161
new InputSet('basic_pkg', ['{lib,web}/**']),
6262
new InputSet('a', ['lib/**']),
6363
];
@@ -71,7 +71,7 @@ main() {
7171
});
7272

7373
test('can list files based on InputSets with globs', () async {
74-
var inputSets = [
74+
var inputSets = <InputSet>[
7575
new InputSet('basic_pkg', ['web/*.txt']),
7676
new InputSet('a', ['lib/*']),
7777
];

test/generate/build_test.dart

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,11 @@ main() {
172172
test('outputs from previous full builds shouldn\'t be inputs to later ones',
173173
() async {
174174
final writer = new InMemoryAssetWriter();
175-
var inputs = {'a|web/a.txt': 'a', 'a|lib/b.txt': 'b'};
176-
var outputs = {'a|web/a.txt.copy': 'a', 'a|lib/b.txt.copy': 'b'};
175+
var inputs = <String, String>{'a|web/a.txt': 'a', 'a|lib/b.txt': 'b'};
176+
var outputs = <String, String>{
177+
'a|web/a.txt.copy': 'a',
178+
'a|lib/b.txt.copy': 'b'
179+
};
177180
// First run, nothing special.
178181
await testPhases(copyAPhaseGroup, inputs, outputs: outputs, writer: writer);
179182
// Second run, should have no extra outputs.
@@ -182,8 +185,11 @@ main() {
182185

183186
test('can recover from a deleted asset_graph.json cache', () async {
184187
final writer = new InMemoryAssetWriter();
185-
var inputs = {'a|web/a.txt': 'a', 'a|lib/b.txt': 'b'};
186-
var outputs = {'a|web/a.txt.copy': 'a', 'a|lib/b.txt.copy': 'b'};
188+
var inputs = <String, String>{'a|web/a.txt': 'a', 'a|lib/b.txt': 'b'};
189+
var outputs = <String, String>{
190+
'a|web/a.txt.copy': 'a',
191+
'a|lib/b.txt.copy': 'b'
192+
};
187193
// First run, nothing special.
188194
await testPhases(copyAPhaseGroup, inputs, outputs: outputs, writer: writer);
189195

tool/travis.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
# Fast fail the script on failures.
88
set -e
99

10-
# Verify that the libraries are error free.
11-
dartanalyzer --fatal-warnings \
12-
lib/build.dart
10+
# Verify that the libraries are error free, requires some strong mode changes
11+
# that are only in the dev channel right now though.
12+
if [ "$TRAVIS_DART_VERSION" != "stable" ]; then
13+
dartanalyzer --fatal-warnings lib/build.dart
14+
fi
1315

1416
# Run the tests.
1517
pub run test

0 commit comments

Comments
 (0)