File tree Expand file tree Collapse file tree 1 file changed +63
-0
lines changed
Expand file tree Collapse file tree 1 file changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ //===----------------------------------------------------------------------===//
2+ //
3+ // This source file is part of the Swift.org open source project
4+ //
5+ // Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
6+ // Licensed under Apache License v2.0 with Runtime Library Exception
7+ //
8+ // See https://swift.org/LICENSE.txt for license information
9+ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+ //
11+ //===----------------------------------------------------------------------===//
12+
13+
14+ import XCTest
15+
16+ final class VariadicGenericsTests : XCTestCase {
17+ func testSimple( ) {
18+ AssertParse (
19+ """
20+ func tuplify<T...>(_ t: (each T)...) -> ((each T)...) {
21+ }
22+ """
23+ )
24+ }
25+
26+ func testRequirement( ) {
27+ AssertParse (
28+ """
29+ func requirement<T...>() where each T: P {
30+ }
31+ """
32+ )
33+ }
34+
35+ func testElementOutsideExpansion( ) {
36+ // This is valid to parse, and becomes invalid during type resolution.
37+ AssertParse (
38+ """
39+ func invalid<T...>(_ t: each T) -> each T {}
40+ """
41+ )
42+ }
43+
44+ func testInvalidPackElement( ) {
45+ AssertParse (
46+ """
47+ func invalid<T...>() -> (each any 1️⃣T) {}
48+ """ ,
49+ diagnostics: [
50+ DiagnosticSpec ( message: " expected ',' in tuple type " )
51+ ]
52+ )
53+
54+ AssertParse (
55+ """
56+ func invalid<T...>(_: each T 1️⃣& P) {}
57+ """ ,
58+ diagnostics: [
59+ DiagnosticSpec ( message: " unexpected code '& P' in parameter clause " )
60+ ]
61+ )
62+ }
63+ }
You can’t perform that action at this time.
0 commit comments