Skip to content

Commit 64c3575

Browse files
committed
[ASTPrinter] Put desugaring constraints for existential types behind a
PrintOptions flag that is only enabled for interface printing.
1 parent 5d22ec7 commit 64c3575

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

include/swift/AST/PrintOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ struct PrintOptions {
285285
/// types.
286286
bool PrintExplicitAny = false;
287287

288+
/// Whether to desugar the constraint for an existential type.
289+
bool DesugarExistentialConstraint = false;
290+
288291
/// Whether to skip keywords with a prefix of underscore such as __consuming.
289292
bool SkipUnderscoredKeywords = false;
290293

lib/AST/ASTPrinter.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ PrintOptions PrintOptions::printSwiftInterfaceFile(ModuleDecl *ModuleToPrint,
146146
result.AlwaysTryPrintParameterLabels = true;
147147
result.PrintSPIs = printSPIs;
148148
result.PrintExplicitAny = true;
149+
result.DesugarExistentialConstraint = true;
149150

150151
// We should print __consuming, __owned, etc for the module interface file.
151152
result.SkipUnderscoredKeywords = false;
@@ -6200,7 +6201,11 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
62006201
// interfaces. Verifying that the underlying type of a
62016202
// protocol typealias is a constriant type is fundamentally
62026203
// circular, so the desugared type should be written in source.
6203-
visit(T->getConstraintType()->getDesugaredType());
6204+
if (Options.DesugarExistentialConstraint) {
6205+
visit(T->getConstraintType()->getDesugaredType());
6206+
} else {
6207+
visit(T->getConstraintType());
6208+
}
62046209
}
62056210

62066211
void visitLValueType(LValueType *T) {

0 commit comments

Comments
 (0)