mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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.
9 lines
358 B
Swift
9 lines
358 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
protocol P<A> {
|
|
associatedtype A
|
|
}
|
|
|
|
func f<each T>(_: some P<repeat each T>) {}
|
|
// expected-error@-1 {{pack expansion 'repeat each T' can only appear in a function parameter list, tuple element, or generic argument of a variadic type}}
|
|
// expected-error@-2 {{generic parameter 'T' is not used in function signature}} |