File tree 2 files changed +35
-0
lines changed
2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -510,6 +510,15 @@ class FileState {
510
510
// Flush exported top-level declarations of all files.
511
511
if (apiSignatureChanged) {
512
512
_libraryCycle? .invalidate ();
513
+
514
+ // If this is a part, invalidate the libraries.
515
+ var libraries = _fsState._partToLibraries[this ];
516
+ if (libraries != null ) {
517
+ for (var library in libraries) {
518
+ library.libraryCycle? .invalidate ();
519
+ }
520
+ }
521
+
513
522
for (FileState file in _fsState._uriToFile.values) {
514
523
file._exportedTopLevelDeclarations = null ;
515
524
}
Original file line number Diff line number Diff line change @@ -2781,6 +2781,32 @@ var b = new B();
2781
2781
expect (_getTopLevelVarType (result.unit, 'b' ), 'B' );
2782
2782
}
2783
2783
2784
+ test_part_getResult_changePart_invalidatesLibraryCycle () async {
2785
+ var a = convertPath ('/test/lib/a.dart' );
2786
+ var b = convertPath ('/test/lib/b.dart' );
2787
+ newFile (a, content: r'''
2788
+ import 'dart:async';
2789
+ part 'b.dart';
2790
+ ''' );
2791
+ driver.addFile (a);
2792
+
2793
+ // Analyze the library without the part.
2794
+ await driver.getResult (a);
2795
+
2796
+ // Create the part file.
2797
+ // This should invalidate library file state (specifically the library
2798
+ // cycle), so that we can re-link the library, and get new dependencies.
2799
+ newFile (b, content: r'''
2800
+ part of 'a.dart';
2801
+ Future<int> f;
2802
+ ''' );
2803
+ driver.changeFile (b);
2804
+
2805
+ // This should not crash.
2806
+ var result = await driver.getResult (b);
2807
+ expect (result.errors, isEmpty);
2808
+ }
2809
+
2784
2810
test_part_getResult_noLibrary () async {
2785
2811
var c = convertPath ('/test/lib/c.dart' );
2786
2812
newFile (c, content: r'''
You can’t perform that action at this time.
0 commit comments