Skip to content

Commit 0682b7a

Browse files
committed
[ast] Move ActorIsolation::printForDiagnostics into ActorIsolation.h to work around libBasic including libAST.
1 parent aafd9f4 commit 0682b7a

File tree

2 files changed

+30
-33
lines changed

2 files changed

+30
-33
lines changed

include/swift/AST/ActorIsolation.h

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,36 @@ class ActorIsolation {
284284
}
285285

286286
void printForDiagnostics(llvm::raw_ostream &os,
287-
StringRef openingQuotationMark = "'") const;
287+
StringRef openingQuotationMark = "'") const {
288+
switch (*this) {
289+
case ActorIsolation::ActorInstance:
290+
os << "actor-isolated";
291+
break;
292+
293+
case ActorIsolation::GlobalActor: {
294+
if (isMainActor()) {
295+
os << "main actor-isolated";
296+
} else {
297+
Type globalActor = getGlobalActor();
298+
os << "global actor " << openingQuotationMark << globalActor.getString()
299+
<< openingQuotationMark << "-isolated";
300+
}
301+
break;
302+
}
303+
case ActorIsolation::Erased:
304+
os << "@isolated(any)";
305+
break;
306+
307+
case ActorIsolation::Nonisolated:
308+
case ActorIsolation::NonisolatedUnsafe:
309+
case ActorIsolation::Unspecified:
310+
os << "nonisolated";
311+
if (*this == ActorIsolation::NonisolatedUnsafe) {
312+
os << "(unsafe)";
313+
}
314+
break;
315+
}
316+
}
288317

289318
SWIFT_DEBUG_DUMP {
290319
print(llvm::dbgs());

lib/AST/TypeCheckRequests.cpp

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,38 +1684,6 @@ ActorIsolation ActorIsolation::subst(SubstitutionMap subs) const {
16841684
llvm_unreachable("unhandled actor isolation kind!");
16851685
}
16861686

1687-
void ActorIsolation::printForDiagnostics(llvm::raw_ostream &os,
1688-
StringRef openingQuotationMark) const {
1689-
switch (*this) {
1690-
case ActorIsolation::ActorInstance:
1691-
os << "actor-isolated";
1692-
break;
1693-
1694-
case ActorIsolation::GlobalActor: {
1695-
if (isMainActor()) {
1696-
os << "main actor-isolated";
1697-
} else {
1698-
Type globalActor = getGlobalActor();
1699-
os << "global actor " << openingQuotationMark << globalActor.getString()
1700-
<< openingQuotationMark << "-isolated";
1701-
}
1702-
break;
1703-
}
1704-
case ActorIsolation::Erased:
1705-
os << "@isolated(any)";
1706-
break;
1707-
1708-
case ActorIsolation::Nonisolated:
1709-
case ActorIsolation::NonisolatedUnsafe:
1710-
case ActorIsolation::Unspecified:
1711-
os << "nonisolated";
1712-
if (*this == ActorIsolation::NonisolatedUnsafe) {
1713-
os << "(unsafe)";
1714-
}
1715-
break;
1716-
}
1717-
}
1718-
17191687
void swift::simple_display(
17201688
llvm::raw_ostream &out, const ActorIsolation &state) {
17211689
if (state.preconcurrency())

0 commit comments

Comments
 (0)