Skip to content

Commit a18c155

Browse files
scheglovCommit Queue
authored andcommitted
Fine. Clear cached 'LibraryFileKind.diagnosticsBundleKey' when dispose the cycle.
Change-Id: Id5ce57471ee79da8c494199d617d3bd630ec6e6b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453641 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]>
1 parent 1fee07c commit a18c155

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

pkg/analyzer/lib/src/dart/analysis/file_state.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,6 +1906,7 @@ class LibraryFileKind extends LibraryOrAugmentationFileKind {
19061906
void disposeLibraryCycle() {
19071907
_libraryCycle?.dispose();
19081908
_libraryCycle = null;
1909+
diagnosticsBundleKey = null;
19091910
}
19101911

19111912
void internal_setLibraryCycle(LibraryCycle? cycle) {

pkg/analyzer/test/src/dart/analysis/driver_test.dart

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95077,6 +95077,66 @@ final y = 0;
9507795077
''');
9507895078
}
9507995079

95080+
test_operation_addFile_later_addPart() async {
95081+
configuration.withCheckLibraryDiagnosticsRequirements = true;
95082+
95083+
var driver = driverFor(testFile);
95084+
var collector = DriverEventCollector(driver, idProvider: idProvider);
95085+
95086+
var b = newFile('$testPackageLibPath/b.dart', r'''
95087+
part 'a.dart';
95088+
void f(A _) {}
95089+
''');
95090+
driver.addFile2(b);
95091+
95092+
// No part `a.dart` yet.
95093+
// Has 2 errors: (1) no part; (2) no class `A`.
95094+
await assertEventsText(collector, r'''
95095+
[status] working
95096+
[operation] analyzeFile
95097+
file: /home/test/lib/b.dart
95098+
library: /home/test/lib/b.dart
95099+
[stream]
95100+
ResolvedUnitResult #0
95101+
path: /home/test/lib/b.dart
95102+
uri: package:test/b.dart
95103+
flags: exists isLibrary
95104+
errors
95105+
5 +8 URI_DOES_NOT_EXIST
95106+
22 +1 UNDEFINED_CLASS
95107+
[operation] analyzedLibrary
95108+
file: /home/test/lib/b.dart
95109+
[status] idle
95110+
''');
95111+
95112+
var a = newFile('$testPackageLibPath/a.dart', r'''
95113+
part of 'b.dart';
95114+
class A {}
95115+
''');
95116+
driver.addFile2(a);
95117+
95118+
// No errors: (1) the part is present; (2) class `A` in the part.
95119+
await assertEventsText(collector, r'''
95120+
[status] working
95121+
[operation] analyzeFile
95122+
file: /home/test/lib/a.dart
95123+
library: /home/test/lib/b.dart
95124+
[stream]
95125+
ResolvedUnitResult #1
95126+
path: /home/test/lib/b.dart
95127+
uri: package:test/b.dart
95128+
flags: exists isLibrary
95129+
[stream]
95130+
ResolvedUnitResult #2
95131+
path: /home/test/lib/a.dart
95132+
uri: package:test/a.dart
95133+
flags: exists isPart
95134+
[operation] analyzedLibrary
95135+
file: /home/test/lib/b.dart
95136+
[status] idle
95137+
''');
95138+
}
95139+
9508095140
test_operation_getErrors_changeImported_affected() async {
9508195141
configuration.withCheckLibraryDiagnosticsRequirements = true;
9508295142

0 commit comments

Comments
 (0)