Skip to content

Commit 74a6350

Browse files
committed
Sema: Split up test/Constraints/type_sequences.swift
1 parent 74312a3 commit 74a6350

File tree

2 files changed

+44
-43
lines changed

2 files changed

+44
-43
lines changed

test/Constraints/type_sequence.swift renamed to test/Constraints/variadic_generic_functions.swift

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
// RUN: %target-typecheck-verify-swift -enable-experimental-variadic-generics
22

3-
struct TupleStruct<First, Rest...> {
4-
var first: First
5-
var rest: (Rest...)
6-
}
7-
83
func debugPrint<T...>(_ items: T...)
94
where T: CustomDebugStringConvertible
105
{
@@ -23,44 +18,6 @@ func min<T...: Comparable>(_ values: T...) -> T? {
2318
return nil
2419
}
2520

26-
func directAliases() {
27-
typealias Tuple<Ts...> = (Ts...)
28-
29-
typealias Many<T, U, V, Ws...> = Tuple<T, U, V, Ws... >
30-
31-
let _: Many<Int, String, Double, Void, Void, Void, Void> = 42 // expected-error {{cannot convert value of type 'Int' to specified type}}
32-
}
33-
34-
func bindPrefix() {
35-
struct Bind<Prefix, U...> {}
36-
37-
typealias TooFew0 = Bind<> // expected-error {{expected type}}
38-
typealias TooFew1 = Bind<String> // OK
39-
typealias TooFew2 = Bind<String, String> // OK
40-
typealias JustRight = Bind<String, String, String> // OK
41-
typealias Oversaturated = Bind<String, String, String, String, String, String, String, String> // OK
42-
}
43-
44-
func bindSuffix() {
45-
struct Bind<U..., Suffix> {}
46-
47-
typealias TooFew0 = Bind<> // expected-error {{expected type}}
48-
typealias TooFew1 = Bind<String> // OK
49-
typealias TooFew2 = Bind<String, String> // OK
50-
typealias JustRight = Bind<String, String, String> // OK
51-
typealias Oversaturated = Bind<String, String, String, String, String, String, String, String> // OK
52-
}
53-
54-
func bindPrefixAndSuffix() {
55-
struct Bind<Prefix, U..., Suffix> {} // expected-note {{generic type 'Bind' declared here}}
56-
57-
typealias TooFew0 = Bind<> // expected-error {{expected type}}
58-
typealias TooFew1 = Bind<String> // expected-error {{generic type 'Bind' specialized with too few type parameters (got 1, but expected at least 2)}}
59-
typealias TooFew2 = Bind<String, String> // OK
60-
typealias JustRight = Bind<String, String, String> // OK
61-
typealias Oversaturated = Bind<String, String, String, String, String, String, String, String> // OK
62-
}
63-
6421
func invalidPacks() {
6522
func monovariadic1() -> (String...) {} // expected-error {{variadic expansion 'String' must contain at least one variadic generic parameter}}
6623
func monovariadic2<T>() -> (T...) {} // expected-error {{variadic expansion 'T' must contain at least one variadic generic parameter}}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// RUN: %target-typecheck-verify-swift -enable-experimental-variadic-generics
2+
3+
struct TupleStruct<First, Rest...> {
4+
var first: First
5+
var rest: (Rest...)
6+
}
7+
8+
func directAliases() {
9+
typealias Tuple<Ts...> = (Ts...)
10+
11+
typealias Many<T, U, V, Ws...> = Tuple<T, U, V, Ws... >
12+
13+
let _: Many<Int, String, Double, Void, Void, Void, Void> = 42 // expected-error {{cannot convert value of type 'Int' to specified type}}
14+
}
15+
16+
func bindPrefix() {
17+
struct Bind<Prefix, U...> {}
18+
19+
typealias TooFew0 = Bind<> // expected-error {{expected type}}
20+
typealias TooFew1 = Bind<String> // OK
21+
typealias TooFew2 = Bind<String, String> // OK
22+
typealias JustRight = Bind<String, String, String> // OK
23+
typealias Oversaturated = Bind<String, String, String, String, String, String, String, String> // OK
24+
}
25+
26+
func bindSuffix() {
27+
struct Bind<U..., Suffix> {}
28+
29+
typealias TooFew0 = Bind<> // expected-error {{expected type}}
30+
typealias TooFew1 = Bind<String> // OK
31+
typealias TooFew2 = Bind<String, String> // OK
32+
typealias JustRight = Bind<String, String, String> // OK
33+
typealias Oversaturated = Bind<String, String, String, String, String, String, String, String> // OK
34+
}
35+
36+
func bindPrefixAndSuffix() {
37+
struct Bind<Prefix, U..., Suffix> {} // expected-note {{generic type 'Bind' declared here}}
38+
39+
typealias TooFew0 = Bind<> // expected-error {{expected type}}
40+
typealias TooFew1 = Bind<String> // expected-error {{generic type 'Bind' specialized with too few type parameters (got 1, but expected at least 2)}}
41+
typealias TooFew2 = Bind<String, String> // OK
42+
typealias JustRight = Bind<String, String, String> // OK
43+
typealias Oversaturated = Bind<String, String, String, String, String, String, String, String> // OK
44+
}

0 commit comments

Comments
 (0)