|
3 | 3 | // REQUIRES: asserts
|
4 | 4 |
|
5 | 5 | func returnTuple1<T...>() -> (repeat each T) { fatalError() }
|
| 6 | +// expected-note@-1 3 {{in call to function 'returnTuple1()'}} |
6 | 7 |
|
7 | 8 | func returnTuple2<T...>() -> (Int, repeat each T) { fatalError() }
|
| 9 | +// expected-note@-1 3 {{in call to function 'returnTuple2()'}} |
8 | 10 |
|
9 | 11 | func returnTupleLabel1<T...>() -> (x: repeat each T) { fatalError() }
|
| 12 | +// expected-note@-1 2 {{in call to function 'returnTupleLabel1()'}} |
10 | 13 |
|
11 | 14 | func returnTupleLabel2<T...>() -> (Int, x: repeat each T) { fatalError() }
|
| 15 | +// expected-note@-1 2 {{in call to function 'returnTupleLabel2()'}} |
12 | 16 |
|
13 | 17 | func returnTupleLabel3<T...>() -> (Int, repeat each T, y: Float) { fatalError() }
|
| 18 | +// expected-note@-1 3 {{in call to function 'returnTupleLabel3()'}} |
14 | 19 |
|
15 |
| -func returnTupleLabel4<T...>() -> (Int, x: repeat each T, y: Float) { fatalError() } // expected-note {{in call to function 'returnTupleLabel4()'}} |
| 20 | +func returnTupleLabel4<T...>() -> (Int, x: repeat each T, y: Float) { fatalError() } |
| 21 | +// expected-note@-1 2 {{in call to function 'returnTupleLabel4()'}} |
16 | 22 |
|
17 | 23 | func returnTupleLabel5<T..., U...>() -> (Int, repeat each T, y: repeat each U) { fatalError() }
|
| 24 | +// expected-note@-1 3 {{in call to function 'returnTupleLabel5()'}} |
18 | 25 |
|
19 |
| -func returnTupleLabel6<T..., U...>() -> (Int, x: repeat each T, y: repeat each U) { fatalError() } // expected-note {{in call to function 'returnTupleLabel6()'}} |
| 26 | +func returnTupleLabel6<T..., U...>() -> (Int, x: repeat each T, y: repeat each U) { fatalError() } |
| 27 | +// expected-note@-1 {{in call to function 'returnTupleLabel6()'}} |
20 | 28 |
|
21 | 29 | func concreteReturnTupleValid() {
|
22 | 30 | let _: () = returnTuple1()
|
@@ -59,11 +67,26 @@ func concreteReturnTupleValid() {
|
59 | 67 | }
|
60 | 68 |
|
61 | 69 | func concreteReturnTypeInvalid() {
|
62 |
| - let _: (x: Int) = returnTuple1() // expected-error {{type of expression is ambiguous without more context}} |
63 |
| - let _: () = returnTuple2() // expected-error {{type of expression is ambiguous without more context}} |
64 |
| - let _: (x: Int) = returnTupleLabel3() // expected-error {{type of expression is ambiguous without more context}} |
65 |
| - let _: (Int, Int, y: Float) = returnTupleLabel4() // expected-error {{type of expression is ambiguous without more context}} |
66 |
| - let _: () = returnTupleLabel5() // expected-error {{type of expression is ambiguous without more context}} |
| 70 | + let _: (x: Int) = returnTuple1() |
| 71 | + // expected-error@-1 {{cannot convert value of type '(T...)' to specified type '(x: Int)'}} |
| 72 | + // expected-error@-2 {{generic parameter 'T' could not be inferred}} |
| 73 | + |
| 74 | + let _: () = returnTuple2() |
| 75 | + // expected-error@-1 {{'(Int, T...)' is not convertible to '()', tuples have a different number of elements}} |
| 76 | + // expected-error@-2 {{generic parameter 'T' could not be inferred}} |
| 77 | + |
| 78 | + let _: (x: Int) = returnTupleLabel3() |
| 79 | + // expected-error@-1 {{'(Int, T..., y: Float)' is not convertible to '(x: Int)', tuples have a different number of elements}} |
| 80 | + // expected-error@-2 {{generic parameter 'T' could not be inferred}} |
| 81 | + |
| 82 | + let _: (Int, Int, y: Float) = returnTupleLabel4() |
| 83 | + // expected-error@-1 {{cannot convert value of type '(Int, x: T..., y: Float)' to specified type '(Int, Int, y: Float)'}} |
| 84 | + // expected-error@-2 {{generic parameter 'T' could not be inferred}} |
| 85 | + |
| 86 | + let _: () = returnTupleLabel5() |
| 87 | + // expected-error@-1 {{'(Int, T..., y: U...)' is not convertible to '()', tuples have a different number of elements}} |
| 88 | + // expected-error@-2 {{generic parameter 'T' could not be inferred}} |
| 89 | + // expected-error@-3 {{generic parameter 'U' could not be inferred}} |
67 | 90 | }
|
68 | 91 |
|
69 | 92 | func genericReturnTupleValid<T...>(_: repeat each T) {
|
@@ -93,30 +116,60 @@ func genericReturnTupleValid<T...>(_: repeat each T) {
|
93 | 116 | }
|
94 | 117 |
|
95 | 118 | func genericReturnTupleInvalid<T...>(_: repeat each T) {
|
96 |
| - let _: (x: repeat each T) = returnTuple1() // expected-error {{type of expression is ambiguous without more context}} |
97 |
| - let _: (x: Int, repeat each T) = returnTuple1() // expected-error {{type of expression is ambiguous without more context}} |
| 119 | + let _: (x: repeat each T) = returnTuple1() |
| 120 | + // expected-error@-1 {{cannot convert value of type '(T...)' to specified type '(x: T...)'}} |
| 121 | + // expected-error@-2 {{generic parameter 'T' could not be inferred}} |
98 | 122 |
|
99 |
| - let _: (Int, x: repeat each T) = returnTuple2() // expected-error {{type of expression is ambiguous without more context}} |
100 |
| - let _: (Int, x: String, repeat each T) = returnTuple2() // expected-error {{type of expression is ambiguous without more context}} |
| 123 | + let _: (x: Int, repeat each T) = returnTuple1() |
| 124 | + // expected-error@-1 {{'(T...)' is not convertible to '(x: Int, T...)', tuples have a different number of elements}} |
| 125 | + // expected-error@-2 {{generic parameter 'T' could not be inferred}} |
101 | 126 |
|
102 |
| - let _: (y: repeat each T) = returnTupleLabel1() // expected-error {{type of expression is ambiguous without more context}} |
103 |
| - let _: (y: Int, repeat each T) = returnTupleLabel1() // expected-error {{type of expression is ambiguous without more context}} |
| 127 | + let _: (Int, x: repeat each T) = returnTuple2() |
| 128 | + // expected-error@-1 {{cannot convert value of type '(Int, T...)' to specified type '(Int, x: T...)'}} |
| 129 | + // expected-error@-2 {{generic parameter 'T' could not be inferred}} |
104 | 130 |
|
105 |
| - let _: (x: repeat each T) = returnTupleLabel2() // expected-error {{type of expression is ambiguous without more context}} |
106 |
| - let _: (Int, y: String, repeat each T) = returnTupleLabel2() // expected-error {{type of expression is ambiguous without more context}} |
| 131 | + let _: (Int, x: String, repeat each T) = returnTuple2() |
| 132 | + // expected-error@-1 {{'(Int, T...)' is not convertible to '(Int, x: String, T...)', tuples have a different number of elements}} |
| 133 | + // expected-error@-2 {{generic parameter 'T' could not be inferred}} |
107 | 134 |
|
108 |
| - let _: (repeat each T, y: Float) = returnTupleLabel3() // expected-error {{type of expression is ambiguous without more context}} |
| 135 | + let _: (y: repeat each T) = returnTupleLabel1() |
| 136 | + // expected-error@-1 {{cannot convert value of type '(x: T...)' to specified type '(y: T...)'}} |
| 137 | + // expected-error@-2 {{generic parameter 'T' could not be inferred}} |
109 | 138 |
|
110 |
| - let _: (Int, String, repeat each T, x: Float) = returnTupleLabel3() // expected-error {{type of expression is ambiguous without more context}} |
| 139 | + let _: (y: Int, repeat each T) = returnTupleLabel1() |
| 140 | + // expected-error@-1 {{'(x: T...)' is not convertible to '(y: Int, T...)', tuples have a different number of elements}} |
| 141 | + // expected-error@-2 {{generic parameter 'T' could not be inferred}} |
| 142 | + |
| 143 | + let _: (x: repeat each T) = returnTupleLabel2() |
| 144 | + // expected-error@-1 {{'(Int, x: T...)' is not convertible to '(x: T...)', tuples have a different number of elements}} |
| 145 | + // expected-error@-2 {{generic parameter 'T' could not be inferred}} |
| 146 | + |
| 147 | + let _: (Int, y: String, repeat each T) = returnTupleLabel2() |
| 148 | + // expected-error@-1 {{'(Int, x: T...)' is not convertible to '(Int, y: String, T...)', tuples have a different number of elements}} |
| 149 | + // expected-error@-2 {{generic parameter 'T' could not be inferred}} |
| 150 | + |
| 151 | + let _: (repeat each T, y: Float) = returnTupleLabel3() |
| 152 | + // expected-error@-1 {{'(Int, T..., y: Float)' is not convertible to '(T..., y: Float)', tuples have a different number of elements}} |
| 153 | + // expected-error@-2 {{generic parameter 'T' could not be inferred}} |
| 154 | + |
| 155 | + let _: (Int, String, repeat each T, x: Float) = returnTupleLabel3() |
| 156 | + // expected-error@-1 {{'(Int, T..., y: Float)' is not convertible to '(Int, String, T..., x: Float)', tuples have a different number of elements}} |
| 157 | + // expected-error@-2 {{generic parameter 'T' could not be inferred}} |
111 | 158 |
|
112 | 159 | let _: (repeat each T, y: Float) = returnTupleLabel4() // expected-error {{'(Int, x: T..., y: Float)' is not convertible to '(T..., y: Float)', tuples have a different number of elements}}
|
113 | 160 | // expected-error@-1 {{generic parameter 'T' could not be inferred}}
|
114 | 161 |
|
115 | 162 | let _: (Int, x: String, y: repeat each T) = returnTupleLabel4() // expected-error {{cannot convert value of type '(Int, x: String, y: Float)' to specified type '(Int, x: String, y: T...)'}}
|
116 | 163 |
|
117 |
| - let _: (Int, repeat each T, x: repeat each T) = returnTupleLabel5() // expected-error {{type of expression is ambiguous without more context}} |
| 164 | + let _: (Int, repeat each T, x: repeat each T) = returnTupleLabel5() |
| 165 | + // expected-error@-1 {{cannot convert value of type '(Int, T..., y: U...)' to specified type '(Int, T..., x: T...)'}} |
| 166 | + // expected-error@-2 {{generic parameter 'T' could not be inferred}} |
| 167 | + // expected-error@-3 {{generic parameter 'U' could not be inferred}} |
118 | 168 |
|
119 |
| - let _: (repeat each T, y: Float, repeat each T) = returnTupleLabel5() // expected-error {{type of expression is ambiguous without more context}} |
| 169 | + let _: (repeat each T, y: Float, repeat each T) = returnTupleLabel5() |
| 170 | + // expected-error@-1 {{cannot convert value of type '(Int, T..., y: U...)' to specified type '(T..., y: Float, T...)'}} |
| 171 | + // expected-error@-2 {{generic parameter 'T' could not be inferred}} |
| 172 | + // expected-error@-3 {{generic parameter 'U' could not be inferred}} |
120 | 173 |
|
121 | 174 | let _: (repeat each T, y: Int) = returnTupleLabel6() // expected-error {{'(Int, x: T..., y: U...)' is not convertible to '(T..., y: Int)', tuples have a different number of elements}}
|
122 | 175 | // expected-error@-1 {{generic parameter 'T' could not be inferred}}
|
|
0 commit comments