Files
swift-mirror/test/Generics/rdar115538574.swift
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

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}}