Skip to content

Commit e9c14cd

Browse files
committed
[ASTPrinter] Print the desugared constraint type following the 'any'
keyword.
1 parent 7a65b6b commit e9c14cd

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6211,7 +6211,12 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
62116211
if (Options.PrintExplicitAny)
62126212
Printer << "any ";
62136213

6214-
visit(T->getConstraintType());
6214+
// FIXME: The desugared type is used here only to support
6215+
// existential types with protocol typealiases in Swift
6216+
// interfaces. Verifying that the underlying type of a
6217+
// protocol typealias is a constriant type is fundamentally
6218+
// circular, so the desugared type should be written in source.
6219+
visit(T->getConstraintType()->getDesugaredType());
62156220
}
62166221

62176222
void visitLValueType(LValueType *T) {

test/ModuleInterface/existential-any.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,11 @@ public struct S {
3838
// CHECK: public var q: any main.Q
3939
public var q: any Q
4040
}
41+
42+
43+
public protocol ProtocolTypealias {
44+
typealias A = P
45+
}
46+
47+
// CHECK: public func dependentExistential<T>(value: (T) -> any main.P) where T : main.ProtocolTypealias
48+
public func dependentExistential<T: ProtocolTypealias>(value: (T) -> T.A) {}

0 commit comments

Comments
 (0)