File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -6473,6 +6473,13 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
6473
6473
if (auto existential = constraint->getAs <ExistentialType>())
6474
6474
constraint = existential->getConstraintType ();
6475
6475
6476
+ // Opaque archetype substitutions are always canonical, so re-sugar the
6477
+ // constraint type using the owning declaration's generic parameter names.
6478
+ auto genericSig = T->getDecl ()->getNamingDecl ()->getInnermostDeclContext ()
6479
+ ->getGenericSignatureOfContext ();
6480
+ if (genericSig)
6481
+ constraint = genericSig->getSugaredType (constraint);
6482
+
6476
6483
visit (constraint);
6477
6484
return ;
6478
6485
}
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 -disable-availability-checking
3
+ // RUN: %target-swift-typecheck-module-from-interface(%t/ParameterizedProtocols.swiftinterface) -module-name ParameterizedProtocols -disable-availability-checking
4
+ // RUN: %FileCheck %s < %t/ParameterizedProtocols.swiftinterface
5
+
6
+ public protocol P < T> {
7
+ associatedtype T
8
+ }
9
+
10
+ public protocol Q < T> : P { }
11
+
12
+ struct S < T> : Q { }
13
+
14
+
15
+ // CHECK-LABEL: public func returnsP() -> some ParameterizedProtocols.P
16
+ public func returnsP( ) -> some P { return S < Int > ( ) }
17
+
18
+ // CHECK-LABEL: public func returnsPInt() -> some ParameterizedProtocols.P<Swift.Int>
19
+ public func returnsPInt( ) -> some P < Int > { return S < Int > ( ) }
20
+
21
+ // CHECK-LABEL: public func returnsPT<T>(_: T) -> some ParameterizedProtocols.P<T>
22
+ public func returnsPT< T> ( _: T ) -> some P < T > { return S < T > ( ) }
23
+
24
+ // CHECK-LABEL: public func returnsPArrayT<T>(_: T) -> some ParameterizedProtocols.P<Swift.Array<T>>
25
+ public func returnsPArrayT< T> ( _: T ) -> some P < Array < T > > { return S < Array < T > > ( ) }
26
+
27
+
28
+ // CHECK-LABEL: public func returnsQ() -> some ParameterizedProtocols.Q
29
+ public func returnsQ( ) -> some Q { return S < Int > ( ) }
30
+
31
+ // CHECK-LABEL: public func returnsQInt() -> some ParameterizedProtocols.Q<Swift.Int>
32
+ public func returnsQInt( ) -> some Q < Int > { return S < Int > ( ) }
33
+
34
+ // CHECK-LABEL: public func returnsQT<T>(_: T) -> some ParameterizedProtocols.Q<T>
35
+ public func returnsQT< T> ( _: T ) -> some Q < T > { return S < T > ( ) }
36
+
37
+ // CHECK-LABEL: public func returnsQArrayT<T>(_: T) -> some ParameterizedProtocols.Q<Swift.Array<T>>
38
+ public func returnsQArrayT< T> ( _: T ) -> some Q < Array < T > > { return S < Array < T > > ( ) }
You can’t perform that action at this time.
0 commit comments