Skip to content

Commit df02862

Browse files
committed
Sema: Disallow SE-0361 with variadic generic types for now
`extension G<Int>` introduces a same-type requirement, and this isn't supported for variadic generic types yet. Make sure we pass a valid source location here to diagnose instead of dropping the error. - Fixes #70432 - Fixes rdar://119613080
1 parent 6baa3de commit df02862

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/AST/RequirementMachine/RequirementMachineRequests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ InferredGenericSignatureRequest::evaluate(
870870
// inferred same-type requirements when building the generic signature of
871871
// an extension whose extended type is a generic typealias.
872872
for (const auto &req : addedRequirements)
873-
requirements.push_back({req, SourceLoc()});
873+
requirements.push_back({req, loc});
874874

875875
desugarRequirements(requirements, inverses, errors);
876876

test/Generics/variadic_generic_types.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,16 @@ func packExpansionInScalarArgument<each T>(_: repeat each T) {
116116
typealias A<U> = U
117117
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}}
118118
}
119+
120+
// Make sure we diagnose instead of silently dropping the same-type requirement
121+
// https://github.com/apple/swift/issues/70432
122+
123+
struct WithPack<each T> {}
124+
125+
// FIXME: The diagnostics are misleading.
126+
127+
extension WithPack<Int, Int> {}
128+
// expected-error@-1 {{same-element requirements are not yet supported}}
129+
130+
extension WithPack where (repeat each T) == (Int, Int) {}
131+
// expected-error@-1 {{generic signature requires types '(repeat each T)' and '(Int, Int)' to be the same}}

0 commit comments

Comments
 (0)