File tree Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -472,20 +472,25 @@ static void checkGenericParams(GenericContext *ownerCtx) {
472
472
return ;
473
473
474
474
auto *decl = ownerCtx->getAsDecl ();
475
- bool isGenericType = isa<GenericTypeDecl >(decl);
475
+ bool isGenericType = isa<NominalTypeDecl >(decl);
476
476
bool hasPack = false ;
477
477
478
478
for (auto gp : *genericParams) {
479
479
// Diagnose generic types with a parameter packs if VariadicGenerics
480
480
// is not enabled.
481
- if (gp->isParameterPack () && isGenericType) {
482
- TypeChecker::checkAvailability (
483
- gp->getSourceRange (),
484
- ownerCtx->getASTContext ().getVariadicGenericTypeAvailability (),
485
- diag::availability_variadic_type_only_version_newer,
486
- ownerCtx);
487
-
488
- if (hasPack) {
481
+ if (gp->isParameterPack ()) {
482
+ // Variadic nominal types require runtime support.
483
+ if (isa<NominalTypeDecl>(decl)) {
484
+ TypeChecker::checkAvailability (
485
+ gp->getSourceRange (),
486
+ ownerCtx->getASTContext ().getVariadicGenericTypeAvailability (),
487
+ diag::availability_variadic_type_only_version_newer,
488
+ ownerCtx);
489
+ }
490
+
491
+ // Variadic nominal and type alias types can only have a single
492
+ // parameter pack.
493
+ if (hasPack && isa<GenericTypeDecl>(decl)) {
489
494
gp->diagnose (diag::more_than_one_pack_in_type);
490
495
}
491
496
Original file line number Diff line number Diff line change 5
5
struct G < each T > { }
6
6
// expected-note@-1 {{add @available attribute to enclosing generic struct}}
7
7
// expected-error@-2 {{parameter packs in generic types are only available in macOS 99.99.0 or newer}}
8
+
9
+ // Type aliases are OK
10
+ typealias A < each T > = ( repeat each T )
You can’t perform that action at this time.
0 commit comments