- // Step 1c: ... finally establish linkage along the reverse uses/augment axis. This is needed to route generated
- // type manifestations (isAddedByUses/isAugmenting) to their type generation sites.
- linkOriginalGenerator(children);
+ final var unlinkedModules = new ArrayList<>(children);
+ while (true) {
+ final boolean progress =
+ progressAndClean(unlinkedModules, ModuleGenerator::linkOriginalGeneratorRecursive)
+ // not '||' because we need the side-effects, which would get short-circuited
+ | progressAndClean(augments, AugmentRequirement::resolve);
+
+ if (augments.isEmpty() && unlinkedModules.isEmpty()) {
+ break;
+ }
+
+ if (!progress) {
+ final var ex = new VerifyException("Failed to make progress on linking of original generators");
+ for (var augment : augments) {
+ ex.addSuppressed(new IllegalStateException(augment + " is incomplete"));
+ }
+ for (var module : unlinkedModules) {
+ ex.addSuppressed(new IllegalStateException(module + " remains unlinked"));
+ }
+ throw ex;
+ }
+ }