File tree Expand file tree Collapse file tree 2 files changed +59
-2
lines changed Expand file tree Collapse file tree 2 files changed +59
-2
lines changed Original file line number Diff line number Diff line change @@ -403,9 +403,15 @@ abstract class FileKind {
403403 return ;
404404 }
405405
406- for (var reference in file.referencingFiles) {
406+ // Take referencing files, stop potential recursion.
407+ var referencingFiles = file.referencingFiles;
408+ file.referencingFiles = {};
409+
410+ // Iterate and restore.
411+ for (var reference in referencingFiles) {
407412 reference.kind.disposeLibraryCycle ();
408413 }
414+ file.referencingFiles = referencingFiles;
409415 }
410416
411417 bool hasPart (PartFileKind partKind) {
@@ -529,7 +535,7 @@ class FileState {
529535 bool isMacroPart = false ;
530536
531537 /// Files that reference this file.
532- final Set <FileState > referencingFiles = {};
538+ Set <FileState > referencingFiles = {};
533539
534540 /// The flag that shows whether the file has an error or warning that
535541 /// might be fixed by a change to another file.
Original file line number Diff line number Diff line change @@ -3248,6 +3248,57 @@ elementFactory
32483248''' );
32493249 }
32503250
3251+ test_newFile_partOfUri_cycle_importSelf () async {
3252+ // https://github.com/dart-lang/sdk/issues/57043
3253+
3254+ var a = newFile ('$testPackageLibPath /a.dart' , r'''
3255+ part 'b.dart';
3256+ ''' );
3257+
3258+ var b = newFile ('$testPackageLibPath /b.dart' , r'''
3259+ part of 'a.dart';
3260+ import '';
3261+ ''' );
3262+
3263+ fileStateFor (a);
3264+ var b_state = fileStateFor (b);
3265+
3266+ assertDriverStateString (testFile, r'''
3267+ files
3268+ /home/test/lib/a.dart
3269+ uri: package:test/a.dart
3270+ current
3271+ id: file_0
3272+ kind: library_0
3273+ libraryImports
3274+ library_2 dart:core synthetic
3275+ partIncludes
3276+ partOfUriKnown_1
3277+ fileKinds: library_0 partOfUriKnown_1
3278+ cycle_0
3279+ dependencies: dart:core
3280+ libraries: library_0
3281+ apiSignature_0
3282+ unlinkedKey: k00
3283+ /home/test/lib/b.dart
3284+ uri: package:test/b.dart
3285+ current
3286+ id: file_1
3287+ kind: partOfUriKnown_1
3288+ uriFile: file_0
3289+ library: library_0
3290+ libraryImports
3291+ notLibrary file_1
3292+ referencingFiles: file_0 file_1
3293+ unlinkedKey: k01
3294+ libraryCycles
3295+ elementFactory
3296+ ''' );
3297+
3298+ // Should not recurse infinitely.
3299+ b_state.kind.disposeLibraryCycle ();
3300+ }
3301+
32513302 test_newFile_partOfUri_doesNotExist () async {
32523303 var a = getFile ('$testPackageLibPath /a.dart' );
32533304
You can’t perform that action at this time.
0 commit comments