File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
test/decl/protocol/conforms Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -923,6 +923,10 @@ AssociatedTypeInference::computeAbstractTypeWitness(
923
923
// If there is a generic parameter of the named type, use that.
924
924
if (auto genericSig = dc->getGenericSignatureOfContext ()) {
925
925
for (auto gp : genericSig.getInnermostGenericParams ()) {
926
+ // Packs cannot witness associated type requirements.
927
+ if (gp->isParameterPack ())
928
+ continue ;
929
+
926
930
if (gp->getName () == assocType->getName ())
927
931
return AbstractTypeWitness (assocType, gp);
928
932
}
Original file line number Diff line number Diff line change
1
+ // RUN: %target-typecheck-verify-swift -enable-experimental-feature VariadicGenerics
2
+
3
+ // Because of -enable-experimental-feature VariadicGenerics
4
+ // REQUIRES: asserts
5
+
6
+ // Generic parameter packs cannot witness associated type requirements
7
+ protocol HasAssoc {
8
+ associatedtype A
9
+ // expected-note@-1 {{protocol requires nested type 'A'; do you want to add it?}}
10
+ }
11
+
12
+ struct HasPack < each A > : HasAssoc { }
13
+ // expected-error@-1 {{type 'HasPack<repeat each A>' does not conform to protocol 'HasAssoc'}}
14
+
15
+ protocol P { }
16
+
17
+ protocol HasPackRequirements {
18
+ func doStuff1< each U > ( _ value: repeat each U ) -> ( repeat Array < each U > )
19
+ func doStuff2< each U > ( _ value: repeat each U ) -> ( repeat Array < each U > )
20
+ }
21
+
22
+ extension HasPackRequirements {
23
+ func doStuff1< each U > ( _ value: repeat each U ) -> ( repeat Array < each U > ) {
24
+ return ( repeat [ each value] )
25
+ }
26
+ }
27
+
28
+ struct ConformsPackRequirements < each T > : HasPackRequirements {
29
+ func doStuff2< each U > ( _ value: repeat each U ) -> ( repeat Array < each U > ) {
30
+ return ( repeat [ each value] )
31
+ }
32
+ }
33
+
34
+
You can’t perform that action at this time.
0 commit comments