Skip to content

Commit 2f44498

Browse files
authored
Merge pull request #8857 from rjmccall/weaken-redelay-assertion
2 parents 418dabf + 91ffc9b commit 2f44498

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

lib/Sema/TypeChecker.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,10 +578,14 @@ static void typeCheckFunctionsAndExternalDecls(TypeChecker &TC) {
578578
// Now that all types have been finalized, run any delayed
579579
// circularity checks.
580580
// This has been written carefully to fail safe + finitely if
581-
// for some reason a type gets re-delayed.
581+
// for some reason a type gets re-delayed in a non-assertions
582+
// build in an otherwise successful build.
583+
// Types can be redelayed in a failing build because we won't
584+
// type-check required declarations from different files.
582585
for (size_t i = 0, e = TC.DelayedCircularityChecks.size(); i != e; ++i) {
583586
TC.checkDeclCircularity(TC.DelayedCircularityChecks[i]);
584-
assert(e == TC.DelayedCircularityChecks.size() &&
587+
assert((e == TC.DelayedCircularityChecks.size() ||
588+
TC.Context.hadError()) &&
585589
"circularity checking for type was re-delayed!");
586590
}
587591
TC.DelayedCircularityChecks.clear();
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
struct External {
2+
var member: Something
3+
}
4+
5+
struct OtherExternal {}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %target-swift-frontend -emit-silgen -verify -primary-file %s %S/Inputs/circularity_multifile_error_helper.swift
2+
3+
// SR-4594
4+
5+
struct A {
6+
var b: AnUndefinedType // expected-error {{use of undeclared type 'AnUndefinedType'}}
7+
}
8+
9+
struct B {
10+
var a : External
11+
}

0 commit comments

Comments
 (0)