File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -341,6 +341,25 @@ void TypeChecker::checkReferencedGenericParams(GenericContext *dc) {
341
341
ReferencedGenericParams.insert (ty->getCanonicalType ());
342
342
return Action::SkipChildren;
343
343
}
344
+
345
+ // Skip the count type, which is always a generic parameter;
346
+ // we don't consider it a reference because it only binds the
347
+ // shape and not the metadata.
348
+ if (auto *expansionTy = ty->getAs <PackExpansionType>()) {
349
+ expansionTy->getPatternType ().walk (*this );
350
+ return Action::SkipChildren;
351
+ }
352
+
353
+ // Don't walk into generic type alias substitutions. This does
354
+ // not constrain `T`:
355
+ //
356
+ // typealias Foo<T> = Int
357
+ // func foo<T>(_: Foo<T>) {}
358
+ if (auto *aliasTy = dyn_cast<TypeAliasType>(ty.getPointer ())) {
359
+ Type (aliasTy->getSinglyDesugaredType ()).walk (*this );
360
+ return Action::SkipChildren;
361
+ }
362
+
344
363
return Action::Continue;
345
364
}
346
365
Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ struct Outer<each T> {
65
65
func packRef< each T > ( _: repeat each T ) where repeat each T : P { }
66
66
67
67
func packMemberRef< each T > ( _: repeat ( each T ) . T) where repeat each T : P { }
68
+ // expected-error@-1 {{generic parameter 'T' is not used in function signature}}
68
69
69
70
// expected-error@+1 {{'each' cannot be applied to non-pack type 'Int'}}{{31-35=}}
70
71
func invalidPackRefEachInt( _: each Int ) { }
@@ -98,3 +99,11 @@ func golden<Z>(_ z: Z) {}
98
99
func hour< each T > ( _ t: repeat each T ) {
99
100
_ = ( repeat golden( each t) )
100
101
}
102
+
103
+ func unusedParameterPack1< each T : Sequence > ( _: repeat ( each T ) . Element) { }
104
+ // expected-error@-1 {{generic parameter 'T' is not used in function signature}}
105
+
106
+ typealias First < T, U> = T
107
+
108
+ func unusedParameterPack2< each T > ( _: repeat First < Int , each T > ) { }
109
+ // expected-error@-1 {{generic parameter 'T' is not used in function signature}}
You can’t perform that action at this time.
0 commit comments