Skip to content

Commit 38dfb99

Browse files
committed
[ASTPrinter] Put desugaring constraints for existential types behind a
PrintOptions flag that is only enabled for interface printing.
1 parent e9c14cd commit 38dfb99

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
@@ -156,6 +156,7 @@ PrintOptions PrintOptions::printSwiftInterfaceFile(ModuleDecl *ModuleToPrint,
156156
result.AlwaysTryPrintParameterLabels = true;
157157
result.PrintSPIs = printSPIs;
158158
result.PrintExplicitAny = true;
159+
result.DesugarExistentialConstraint = true;
159160

160161
// We should print __consuming, __owned, etc for the module interface file.
161162
result.SkipUnderscoredKeywords = false;
@@ -6216,7 +6217,11 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
62166217
// interfaces. Verifying that the underlying type of a
62176218
// protocol typealias is a constriant type is fundamentally
62186219
// circular, so the desugared type should be written in source.
6219-
visit(T->getConstraintType()->getDesugaredType());
6220+
if (Options.DesugarExistentialConstraint) {
6221+
visit(T->getConstraintType()->getDesugaredType());
6222+
} else {
6223+
visit(T->getConstraintType());
6224+
}
62206225
}
62216226

62226227
void visitLValueType(LValueType *T) {

0 commit comments

Comments
 (0)