Skip to content

Sema: Disallow SE-0361 with variadic generic types for now #81304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ InferredGenericSignatureRequest::evaluate(
// inferred same-type requirements when building the generic signature of
// an extension whose extended type is a generic typealias.
for (const auto &req : addedRequirements)
requirements.push_back({req, SourceLoc()});
requirements.push_back({req, loc});

desugarRequirements(requirements, inverses, errors);

Expand Down
13 changes: 13 additions & 0 deletions test/Generics/variadic_generic_types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,16 @@ func packExpansionInScalarArgument<each T>(_: repeat each T) {
typealias A<U> = U
typealias One = A<repeat each T> // expected-error {{pack expansion 'repeat each T' can only appear in a function parameter list, tuple element, or generic argument of a variadic type}}
}

// Make sure we diagnose instead of silently dropping the same-type requirement
// https://github.com/apple/swift/issues/70432

struct WithPack<each T> {}

// FIXME: The diagnostics are misleading.

extension WithPack<Int, Int> {}
// expected-error@-1 {{same-element requirements are not yet supported}}

extension WithPack where (repeat each T) == (Int, Int) {}
// expected-error@-1 {{generic signature requires types '(repeat each T)' and '(Int, Int)' to be the same}}