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 @@ -343,6 +343,25 @@ void TypeChecker::checkReferencedGenericParams(GenericContext *dc) {
343
343
ReferencedGenericParams.insert (ty->getCanonicalType ());
344
344
return Action::SkipChildren;
345
345
}
346
+
347
+ // Skip the count type, which is always a generic parameter;
348
+ // we don't consider it a reference because it only binds the
349
+ // shape and not the metadata.
350
+ if (auto *expansionTy = ty->getAs <PackExpansionType>()) {
351
+ expansionTy->getPatternType ().walk (*this );
352
+ return Action::SkipChildren;
353
+ }
354
+
355
+ // Don't walk into generic type alias substitutions. This does
356
+ // not constrain `T`:
357
+ //
358
+ // typealias Foo<T> = Int
359
+ // func foo<T>(_: Foo<T>) {}
360
+ if (auto *aliasTy = dyn_cast<TypeAliasType>(ty.getPointer ())) {
361
+ Type (aliasTy->getSinglyDesugaredType ()).walk (*this );
362
+ return Action::SkipChildren;
363
+ }
364
+
346
365
return Action::Continue;
347
366
}
348
367
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'}}
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