Skip to content

Commit b2c11e8

Browse files
authored
Fix null error. (#4056)
* Fix null error. * Add second test case.
1 parent 3ff3de4 commit b2c11e8

File tree

10 files changed

+89
-27
lines changed

10 files changed

+89
-27
lines changed

build/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.5.3-wip
2+
3+
- Use `build_runner_core` 9.1.1.
4+
15
## 2.5.2
26

37
- Use `build_runner_core` 9.1.0.

build/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: build
2-
version: 2.5.2
2+
version: 2.5.3-wip
33
description: A package for authoring build_runner compatible code generators.
44
repository: https://github.com/dart-lang/build/tree/master/build
55
resolution: workspace
@@ -10,7 +10,7 @@ environment:
1010
dependencies:
1111
analyzer: '>=6.9.0 <8.0.0'
1212
async: ^2.5.0
13-
build_runner_core: '9.1.0'
13+
build_runner_core: '9.1.1-wip'
1414
built_collection: ^5.1.1
1515
built_value: ^8.9.5
1616
convert: ^3.0.0
@@ -24,7 +24,7 @@ dependencies:
2424
pool: ^1.5.0
2525

2626
dev_dependencies:
27-
build_resolvers: '2.5.2'
27+
build_resolvers: '2.5.3-wip'
2828
build_test: ^3.1.0
2929
built_value_generator: ^8.9.5
3030
dart_flutter_team_lints: ^3.1.0

build_resolvers/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
## 2.5.3-wip
2+
3+
- Use `build_runner_core` 9.1.1.
4+
15
## 2.5.2
26

37
- Simplify warnings for outdated `analyzer`.
48

59
## 2.5.1
610

7-
- Use `build_runner_core` 2.5.1.
11+
- Use `build_runner_core` 9.0.1.
812

913
## 2.5.0
1014

build_resolvers/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: build_resolvers
2-
version: 2.5.2
2+
version: 2.5.3-wip
33
description: Resolve Dart code in a Builder
44
repository: https://github.com/dart-lang/build/tree/master/build_resolvers
55
resolution: workspace
@@ -10,8 +10,8 @@ environment:
1010
dependencies:
1111
analyzer: '>=6.9.0 <8.0.0'
1212
async: ^2.5.0
13-
build: '2.5.2'
14-
build_runner_core: '9.1.0'
13+
build: '2.5.3-wip'
14+
build_runner_core: '9.1.1-wip'
1515
collection: ^1.17.0
1616
convert: ^3.1.1
1717
crypto: ^3.0.0

build_runner/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 2.5.3-wip
2+
3+
- Bug fix: fix corner case with checked in generated output that could cause
4+
a crash.
5+
16
## 2.5.2
27

38
- Simplify warnings for outdated `analyzer`.

build_runner/pubspec.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: build_runner
2-
version: 2.5.2
2+
version: 2.5.3-wip
33
description: A build system for Dart code generation and modular compilation.
44
repository: https://github.com/dart-lang/build/tree/master/build_runner
55
resolution: workspace
@@ -16,11 +16,11 @@ dependencies:
1616
analyzer: '>=4.4.0 <8.0.0'
1717
args: ^2.0.0
1818
async: ^2.5.0
19-
build: '2.5.2'
19+
build: '2.5.3-wip'
2020
build_config: ">=1.1.0 <1.2.0"
2121
build_daemon: ^4.0.0
22-
build_resolvers: '2.5.2'
23-
build_runner_core: '9.1.0'
22+
build_resolvers: '2.5.3-wip'
23+
build_runner_core: '9.1.1-wip'
2424
code_builder: ^4.2.0
2525
collection: ^1.15.0
2626
crypto: ^3.0.0

build_runner_core/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 9.1.1-wip
2+
3+
- Bug fix: fix corner case with checked in generated output that could cause
4+
a crash.
5+
16
## 9.1.0
27

38
- More detailed tracking of reads for the benefit of `build_test`.

build_runner_core/lib/src/asset_graph/graph.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class AssetGraph implements GeneratedAssetHider {
124124
);
125125
// Pre-emptively compute digests for the nodes we know have outputs.
126126
await graph._setDigests(
127-
sources.where((id) => graph.get(id)!.primaryOutputs.isNotEmpty),
127+
sources.where((id) => graph.get(id)?.primaryOutputs.isNotEmpty == true),
128128
digestReader,
129129
);
130130
// Always compute digests for all internal nodes.
@@ -481,6 +481,8 @@ class AssetGraph implements GeneratedAssetHider {
481481
///
482482
/// If [placeholders] is supplied they will be added to [newSources] to create
483483
/// the full input set.
484+
///
485+
/// May remove nodes if sources overlap with generated outputs.
484486
void _addOutputsForSources(
485487
BuildPhases buildPhases,
486488
Set<AssetId> newSources,

build_runner_core/pubspec.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: build_runner_core
2-
version: 9.1.0
2+
version: 9.1.1-wip
33
description: Core tools to organize the structure of a build and run Builders.
44
repository: https://github.com/dart-lang/build/tree/master/build_runner_core
55
resolution: workspace
@@ -15,10 +15,10 @@ platforms:
1515
dependencies:
1616
analyzer: '>=6.9.0 <8.0.0'
1717
async: ^2.5.0
18-
build: '2.5.2'
18+
build: '2.5.3-wip'
1919
build_config: ^1.0.0
20-
build_resolvers: '2.5.2'
21-
build_runner: '2.5.2'
20+
build_resolvers: '2.5.3-wip'
21+
build_runner: '2.5.3-wip'
2222
built_collection: ^5.1.1
2323
built_value: ^8.10.1
2424
collection: ^1.15.0

build_runner_core/test/invalidation/checked_in_output_test.dart

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ void main() {
1111

1212
setUp(() {
1313
tester = InvalidationTester();
14-
15-
// Start with output source on disk.
16-
//
17-
// The ordering of sources matters because a different codepath in
18-
// `graph.dart` is triggered depending on whether a source is first
19-
// processed as an input or as a generated output of another input.
20-
//
21-
// So for `a` have the output come first, and for `b` the input come
22-
// first.
23-
tester.sources(['a.g', 'a', 'b', 'b.g']);
2414
});
2515

2616
group('a <== a.g, a <== a.other', () {
2717
setUp(() {
18+
// Start with output source on disk.
19+
//
20+
// The ordering of sources matters because a different codepath in
21+
// `graph.dart` is triggered depending on whether a source is first
22+
// processed as an input or as a generated output of another input.
23+
//
24+
// So for `a` have the output come first, and for `b` the input come
25+
// first.
26+
tester.sources(['a.g', 'a', 'b', 'b.g']);
27+
2828
tester.builder(from: '', to: '.g', outputIsVisible: true)
2929
..reads('')
3030
..writes('.g');
@@ -37,7 +37,7 @@ void main() {
3737
test('checked in outputs are not treated as inputs', () async {
3838
expect(
3939
await tester.build(),
40-
// If outputs were treated by inputs there would be outputs created like
40+
// If outputs were treated as inputs there would be outputs created like
4141
// `a.g.g.other`.
4242
Result(
4343
written: [
@@ -52,4 +52,46 @@ void main() {
5252
);
5353
});
5454
});
55+
56+
group('a <== a.g', () {
57+
setUp(() {
58+
// Start with output source on disk that the build would not actually
59+
// write: with the output of a previous build used as input.
60+
//
61+
// The order matters because it affects the codepath in `graph.dart`.
62+
tester.sources(['a.g.g', 'a.g', 'a']);
63+
64+
tester.builder(from: '', to: '.g', outputIsVisible: true)
65+
..reads('')
66+
..writes('.g');
67+
});
68+
69+
test('can ignore multiple level pregenerated output', () async {
70+
expect(await tester.build(), Result(written: ['a.g']));
71+
});
72+
});
73+
74+
group('a <== a.g <== a.g.other', () {
75+
setUp(() {
76+
// Start with output source on disk that the build would not actually
77+
// write: with the output of a previous build used as input.
78+
//
79+
// The order matters because it affects the codepath in `graph.dart`.
80+
tester.sources(['a.g.other.g', 'a.g.other', 'a.g', 'a']);
81+
82+
tester.builder(from: '', to: '.g', outputIsVisible: true)
83+
..reads('')
84+
..writes('.g');
85+
tester.builder(from: '.g', to: '.g.other', outputIsVisible: true)
86+
..reads('.g')
87+
..writes('.g.other');
88+
});
89+
90+
test(
91+
'can ignore multiple level pregenerated output from two builders',
92+
() async {
93+
expect(await tester.build(), Result(written: ['a.g', 'a.g.other']));
94+
},
95+
);
96+
});
5597
}

0 commit comments

Comments
 (0)