File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -6466,6 +6466,13 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
6466
6466
if (auto existential = constraint->getAs <ExistentialType>())
6467
6467
constraint = existential->getConstraintType ();
6468
6468
6469
+ // Opaque archetype substitutions are always canonical, so re-sugar the
6470
+ // constraint type using the owning declaration's generic parameter names.
6471
+ auto genericSig = T->getDecl ()->getNamingDecl ()->getInnermostDeclContext ()
6472
+ ->getGenericSignatureOfContext ();
6473
+ if (genericSig)
6474
+ constraint = genericSig->getSugaredType (constraint);
6475
+
6469
6476
visit (constraint);
6470
6477
return ;
6471
6478
}
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: %target-swift-emit-module-interface(%t/ParameterizedProtocols.swiftinterface) %s -module-name ParameterizedProtocols
3
+ // RUN: %target-swift-typecheck-module-from-interface(%t/ParameterizedProtocols.swiftinterface) -module-name ParameterizedProtocols
4
+ // RUN: %FileCheck %s < %t/ParameterizedProtocols.swiftinterface
5
+
6
+ public protocol P < T> {
7
+ associatedtype T
8
+ }
9
+
10
+ struct S < T> : P { }
11
+
12
+ // CHECK-LABEL: public func returnsP() -> some ParameterizedProtocols.P
13
+ public func returnsP( ) -> some P { return S < Int > ( ) }
14
+
15
+ // CHECK-LABEL: public func returnsPInt() -> some ParameterizedProtocols.P<Swift.Int>
16
+ public func returnsPInt( ) -> some P < Int > { return S < Int > ( ) }
17
+
18
+ // CHECK-LABEL: public func returnsPT<T>(_: T) -> some ParameterizedProtocols.P<T>
19
+ public func returnsPT< T> ( _: T ) -> some P < T > { return S < T > ( ) }
You can’t perform that action at this time.
0 commit comments