Skip to content

Weaken the circularity re-delay assertion when errors have been emitted. #8857

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/Sema/TypeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,10 +578,14 @@ static void typeCheckFunctionsAndExternalDecls(TypeChecker &TC) {
// Now that all types have been finalized, run any delayed
// circularity checks.
// This has been written carefully to fail safe + finitely if
// for some reason a type gets re-delayed.
// for some reason a type gets re-delayed in a non-assertions
// build in an otherwise successful build.
// Types can be redelayed in a failing build because we won't
// type-check required declarations from different files.
for (size_t i = 0, e = TC.DelayedCircularityChecks.size(); i != e; ++i) {
TC.checkDeclCircularity(TC.DelayedCircularityChecks[i]);
assert(e == TC.DelayedCircularityChecks.size() &&
assert((e == TC.DelayedCircularityChecks.size() ||
TC.Context.hadError()) &&
"circularity checking for type was re-delayed!");
}
TC.DelayedCircularityChecks.clear();
Expand Down
5 changes: 5 additions & 0 deletions test/Sema/Inputs/circularity_multifile_error_helper.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
struct External {
var member: Something
}

struct OtherExternal {}
11 changes: 11 additions & 0 deletions test/Sema/circularity_multifile_error.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// RUN: %target-swift-frontend -emit-silgen -verify -primary-file %s %S/Inputs/circularity_multifile_error_helper.swift

// SR-4594

struct A {
var b: AnUndefinedType // expected-error {{use of undeclared type 'AnUndefinedType'}}
}

struct B {
var a : External
}