Commit Graph

2 Commits

Author SHA1 Message Date
Slava Pestov
73c18fb668 Sema: Better distinguish scalar from variadic generic argument positions, and reject pack expansion types there
We used to disallow pack expansions in generic argument lists of
protocols, but allow them for all other nominal types. However,
we only actually checked that the pack expansions match up if
the type itself was variadic.

Fix this by repurposing Context::ProtocolGenericArgument into
Context::ScalarGenericArgument, and using that when the type does
not have a parameter pack.

Context::GenericArgument is now Context::VariadicGenericArgument,
and we only use it if the type has a parameter pack, in which case
we use the PackMatcher, so any pack expansions in the wrong place
are caught there.

Fixes rdar://116716014 and https://github.com/apple/swift/issues/69088.
2023-10-11 10:39:26 -04:00
Slava Pestov
b6f8f81ec1 Sema: Don't allow PackExpansionType in the generic arguments of a ParameterizedProtocolType
We already had a separate TypeResolverContext::ProtocolGenericArgument that
did not allow PackExpansionTypes, but it was never used.

Fixes rdar://problem/115538574.
2023-09-19 23:03:59 -04:00