Skip to content

Commit da8d035

Browse files
committed
Gardening: Migrate test suite to GH issues: Constraints (2/5)
1 parent b0fb7c5 commit da8d035

File tree

9 files changed

+196
-156
lines changed

9 files changed

+196
-156
lines changed

test/Constraints/argument_matching.swift

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -89,27 +89,24 @@ somekeywords1(x: 1, y: 2, z: 3) // expected-error{{extraneous argument label 'x:
8989
somekeywords1(1, 2, 3) // expected-error{{missing argument labels 'y:z:' in call}}{{18-18=y: }}{{21-21=z: }}
9090
somekeywords1(x: 1, 2, z: 3) // expected-error{{incorrect argument labels in call (have 'x:_:z:', expected '_:y:z:')}}{{15-18=}}{{21-21=y: }}
9191

92-
// SR-2242: poor diagnostic when argument label is omitted
93-
94-
func r27212391(x: Int, _ y: Int) {
95-
let _: Int = x + y
96-
}
97-
98-
func r27212391(a: Int, x: Int, _ y: Int) {
99-
let _: Int = a + x + y
92+
// https://github.com/apple/swift/issues/44849
93+
// Poor diagnostic when argument label is omitted
94+
do {
95+
func f(x: Int, _ y: Int) {}
96+
func f(a: Int, x: Int, _ y: Int) {}
97+
98+
f(3, 5) // expected-error {{missing argument label 'x:' in call}}
99+
f(3, y: 5) // expected-error {{incorrect argument labels in call (have '_:y:', expected 'x:_:')}}
100+
f(3, x: 5) // expected-error {{argument 'x' must precede unnamed argument #1}} {{5-5=x: 5, }} {{6-12=}}
101+
f(y: 3, x: 5) // expected-error {{incorrect argument labels in call (have 'y:x:', expected 'x:_:')}} {{5-6=x}} {{11-14=}}
102+
f(y: 3, 5) // expected-error {{incorrect argument label in call (have 'y:_:', expected 'x:_:')}}
103+
f(x: 3, x: 5) // expected-error {{extraneous argument label 'x:' in call}}
104+
f(a: 1, 3, y: 5) // expected-error {{incorrect argument labels in call (have 'a:_:y:', expected 'a:x:_:')}}
105+
f(1, x: 3, y: 5) // expected-error {{incorrect argument labels in call (have '_:x:y:', expected 'a:x:_:')}}
106+
f(a: 1, y: 3, x: 5) // expected-error {{incorrect argument labels in call (have 'a:y:x:', expected 'a:x:_:')}}
107+
f(a: 1, 3, x: 5) // expected-error {{argument 'x' must precede unnamed argument #2}} {{11-11=x: 5, }} {{12-18=}}
100108
}
101109

102-
r27212391(3, 5) // expected-error {{missing argument label 'x:' in call}}
103-
r27212391(3, y: 5) // expected-error {{incorrect argument labels in call (have '_:y:', expected 'x:_:')}}
104-
r27212391(3, x: 5) // expected-error {{argument 'x' must precede unnamed argument #1}} {{11-11=x: 5, }} {{12-18=}}
105-
r27212391(y: 3, x: 5) // expected-error {{incorrect argument labels in call (have 'y:x:', expected 'x:_:')}} {{11-12=x}} {{17-20=}}
106-
r27212391(y: 3, 5) // expected-error {{incorrect argument label in call (have 'y:_:', expected 'x:_:')}}
107-
r27212391(x: 3, x: 5) // expected-error {{extraneous argument label 'x:' in call}}
108-
r27212391(a: 1, 3, y: 5) // expected-error {{incorrect argument labels in call (have 'a:_:y:', expected 'a:x:_:')}}
109-
r27212391(1, x: 3, y: 5) // expected-error {{incorrect argument labels in call (have '_:x:y:', expected 'a:x:_:')}}
110-
r27212391(a: 1, y: 3, x: 5) // expected-error {{incorrect argument labels in call (have 'a:y:x:', expected 'a:x:_:')}}
111-
r27212391(a: 1, 3, x: 5) // expected-error {{argument 'x' must precede unnamed argument #2}} {{17-17=x: 5, }} {{18-24=}}
112-
113110
// -------------------------------------------
114111
// Out-of-order keywords
115112
// -------------------------------------------
@@ -1718,8 +1715,10 @@ struct DiagnoseAllLabels {
17181715
}
17191716
}
17201717

1721-
// SR-13135: Type inference regression in Swift 5.3 - can't infer a type of @autoclosure result.
1722-
func sr13135() {
1718+
/// https://github.com/apple/swift/issues/55581
1719+
/// Type inference regression in Swift 5.3 - can't infer a type of
1720+
/// `@autoclosure` result
1721+
do {
17231722
struct Foo {
17241723
var bar: [Int] = []
17251724
}
@@ -1734,12 +1733,13 @@ func sr13135() {
17341733
foo(Foo().bar, [baz])
17351734
}
17361735

1737-
// SR-13240
1738-
func twoargs(_ x: String, _ y: String) {}
1736+
// https://github.com/apple/swift/issues/55681
1737+
do {
1738+
func twoargs(_ x: String, _ y: String) {}
17391739

1740-
func test() {
17411740
let x = 1
1742-
twoargs(x, x) // expected-error 2 {{cannot convert value of type 'Int' to expected argument type 'String'}}
1741+
twoargs(x, x)
1742+
// expected-error@-1 2 {{cannot convert value of type 'Int' to expected argument type 'String'}}
17431743
}
17441744

17451745
infix operator ---

test/Constraints/array_literal.swift

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,15 @@ let routerFruit = Company(
318318
]
319319
)
320320

321-
// Infer [[Int]] for SR3786aa.
322-
// FIXME: As noted in SR-3786, this was the behavior in Swift 3, but
323-
// it seems like the wrong choice and is less by design than by
324-
// accident.
325-
let SR3786a: [Int] = [1, 2, 3]
326-
let SR3786aa = [SR3786a.reversed(), SR3786a]
321+
// https://github.com/apple/swift/issues/46371
322+
do {
323+
let x: [Int] = [1, 2, 3]
324+
325+
// Infer '[[Int]]'.
326+
// FIXME: As noted in the issue, this was the behavior in Swift 3, but
327+
// it seems like the wrong choice and is less by design than by accident.
328+
let _ = [x.reversed(), x]
329+
}
327330

328331
// Conditional conformance
329332
protocol P { }
@@ -344,19 +347,19 @@ func testConditional(i: Int, s: String) {
344347
}
345348

346349

347-
// SR-8385
348-
enum SR8385: ExpressibleByStringLiteral {
349-
case text(String)
350-
init(stringLiteral value: String) {
351-
self = .text(value)
350+
// https://github.com/apple/swift/issues/50912
351+
do {
352+
enum Enum: ExpressibleByStringLiteral {
353+
case text(String)
354+
init(stringLiteral value: String) {
355+
self = .text(value)
356+
}
352357
}
353-
}
354358

355-
func testSR8385() {
356-
let _: [SR8385] = [SR8385("hello")]
357-
let _: [SR8385] = [.text("hello")]
358-
let _: [SR8385] = ["hello", SR8385.text("world")]
359-
let _: [SR8385] = ["hello", .text("world")]
359+
let _: [Enum] = [Enum("hello")]
360+
let _: [Enum] = [.text("hello")]
361+
let _: [Enum] = ["hello", Enum.text("world")]
362+
let _: [Enum] = ["hello", .text("world")]
360363
}
361364

362365
struct TestMultipleOverloadedInits {

test/Constraints/construction.swift

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -153,23 +153,26 @@ extension S3 {
153153

154154
let s3b = S3(maybe: s3a)
155155

156-
// SR-5245 - Erroneous diagnostic - Type of expression is ambiguous without more context
157-
class SR_5245 {
158-
struct S {
159-
enum E {
160-
case e1
161-
case e2
162-
}
163-
164-
let e: [E]
165-
}
156+
// https://github.com/apple/swift/issues/47820
157+
// Erroneous diagnostic: type of expression is ambiguous without more context
158+
do {
159+
class C {
160+
struct S {
161+
enum E {
162+
case e1
163+
case e2
164+
}
165+
166+
let e: [E]
167+
}
168+
169+
init(s: S) {}
170+
}
166171

167-
init(s: S) {}
172+
C(s: C.S(f: [.e1, .e2]))
173+
// expected-error@-1 {{incorrect argument label in call (have 'f:', expected 'e:')}} {{12-13=e}}
168174
}
169175

170-
SR_5245(s: SR_5245.S(f: [.e1, .e2]))
171-
// expected-error@-1 {{incorrect argument label in call (have 'f:', expected 'e:')}} {{22-23=e}}
172-
173176
// rdar://problem/34670592 - Compiler crash on heterogeneous collection literal
174177
_ = Array([1, "hello"]) // Ok
175178

@@ -219,8 +222,10 @@ func rdar_50668864() {
219222
}
220223
}
221224

222-
// SR-10837 (rdar://problem/51442825) - init partial application regression
223-
func sr_10837() {
225+
/// rdar://problem/51442825
226+
/// https://github.com/apple/swift/issues/53227
227+
/// `init` partial application regression
228+
do {
224229
struct S {
225230
let value: Int
226231

test/Constraints/diagnostics_swift4.swift

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
// RUN: %target-typecheck-verify-swift -swift-version 4
22

3-
// SR-2505: "Call arguments did not match up" assertion
4-
5-
func sr_2505(_ a: Any) {} // expected-note {{}}
6-
sr_2505() // expected-error {{missing argument for parameter #1 in call}}
7-
sr_2505(a: 1) // expected-error {{extraneous argument label 'a:' in call}}
8-
sr_2505(1, 2) // expected-error {{extra argument in call}}
9-
sr_2505(a: 1, 2) // expected-error {{extra argument in call}}
3+
// https://github.com/apple/swift/issues/45110
4+
// Call arguments did not match up assertion
5+
6+
func f_45110(_ a: Any) {} // expected-note {{}}
7+
do {
8+
f_45110() // expected-error {{missing argument for parameter #1 in call}}
9+
f_45110(a: 1) // expected-error {{extraneous argument label 'a:' in call}}
10+
f_45110(1, 2) // expected-error {{extra argument in call}}
11+
f_45110(a: 1, 2) // expected-error {{extra argument in call}}
12+
}
1013

11-
struct C_2505 {
14+
struct S_45110 {
1215
init(_ arg: Any) {
1316
}
1417
}
1518

16-
protocol P_2505 {
19+
protocol P_45110 {
1720
}
1821

19-
extension C_2505 {
20-
init<T>(from: [T]) where T: P_2505 {
22+
extension S_45110 {
23+
init<T>(from: [T]) where T: P_45110 {
2124
}
2225
}
2326

24-
class C2_2505: P_2505 {
27+
class C_45110: P_45110 {
2528
}
2629

27-
let c_2505 = C_2505(arg: [C2_2505()]) // expected-error {{extraneous argument label 'arg:' in call}}
30+
let _ = S_45110(arg: [C_45110()]) // expected-error {{extraneous argument label 'arg:' in call}}
2831

2932
// rdar://problem/31898542 - Swift 4: 'type of expression is ambiguous without more context' errors, without a fixit
3033

test/Constraints/fixes.swift

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ var someInt = co.a // expected-error{{value of optional type 'C?' must be unwrap
153153
// expected-note@-1{{chain the optional using '?' to access member 'a' only for non-'nil' base values}}{{17-17=?}}
154154
// expected-note@-2{{force-unwrap using '!' to abort execution if the optional value contains 'nil'}}{{17-17=!}}
155155

156-
// SR-839
156+
// https://github.com/apple/swift/issues/43451
157157
struct Q {
158158
let s: String?
159159
}
@@ -172,19 +172,22 @@ let c = q.s.utf8 // expected-error{{value of optional type 'String?' must be unw
172172
// expected-note@-1{{chain the optional using '?' to access member 'utf8' only for non-'nil' base values}}{{12-12=?}}
173173
// expected-note@-2{{force-unwrap using '!' to abort execution if the optional value contains 'nil'}}{{12-12=!}}
174174

175-
// SR-1116
176-
struct S1116 {
177-
var s: Int?
178-
}
175+
// https://github.com/apple/swift/issues/43729
176+
do {
177+
struct S {
178+
var s: Int?
179+
}
179180

180-
let a1116: [S1116] = []
181-
var s1116 = Set(1...10).subtracting(a1116.map({ $0.s })) // expected-error {{value of optional type 'Int?' must be unwrapped to a value of type 'Int'}}
182-
// expected-note@-1{{coalesce using '??' to provide a default when the optional value contains 'nil'}} {{53-53= ?? <#default value#>}}
183-
// expected-note@-2{{force-unwrap using '!' to abort execution if the optional value contains 'nil'}} {{53-53=!}}
181+
let x: [S] = []
182+
var y = Set(1...10).subtracting(x.map({ $0.s })) // expected-error {{value of optional type 'Int?' must be unwrapped to a value of type 'Int'}}
183+
// expected-note@-1{{coalesce using '??' to provide a default when the optional value contains 'nil'}} {{47-47= ?? <#default value#>}}
184+
// expected-note@-2{{force-unwrap using '!' to abort execution if the optional value contains 'nil'}} {{47-47=!}}
185+
}
184186

185187
func makeArray<T>(_ x: T) -> [T] { [x] }
186188

187-
func sr12399(_ x: Int?) {
189+
// https://github.com/apple/swift/issues/54837
190+
func f_54837(_ x: Int?) {
188191
_ = Set(0...10).subtracting(makeArray(x)) // expected-error {{value of optional type 'Int?' must be unwrapped to a value of type 'Int'}}
189192
// expected-note@-1{{coalesce using '??' to provide a default when the optional value contains 'nil'}} {{42-42= ?? <#default value#>}}
190193
// expected-note@-2{{force-unwrap using '!' to abort execution if the optional value contains 'nil'}} {{42-42=!}}
@@ -320,7 +323,7 @@ let _: Int? = thing?.f() // expected-error {{value of optional type 'Int??' must
320323
// expected-note@-1{{coalesce}}
321324
// expected-note@-2{{force-unwrap}}
322325

323-
// SR-9851 - https://bugs.swift.org/browse/SR-9851
326+
// https://github.com/apple/swift/issues/52262
324327
func coalesceWithParensRootExprFix() {
325328
let optionalBool: Bool? = false
326329
if !optionalBool { } // expected-error{{value of optional type 'Bool?' must be unwrapped to a value of type 'Bool'}}
@@ -342,7 +345,7 @@ func test_explicit_call_with_overloads() {
342345
// expected-error@-1 {{function produces expected type 'Int'; did you mean to call it with '()'?}} {{14-14=()}}
343346
}
344347

345-
// SR-11476
348+
// https://github.com/apple/swift/issues/53876
346349
func testKeyPathSubscriptArgFixes(_ fn: @escaping () -> Int) {
347350
struct S {
348351
subscript(x: Int) -> Int { x }
@@ -357,7 +360,8 @@ func testKeyPathSubscriptArgFixes(_ fn: @escaping () -> Int) {
357360
_ = \S.[fn] // expected-error {{function produces expected type 'Int'; did you mean to call it with '()'?}} {{13-13=()}}
358361
}
359362

360-
func sr12426(a: Any, _ str: String?) {
363+
// https://github.com/apple/swift/issues/54865
364+
func f_54865(a: Any, _ str: String?) {
361365
a == str // expected-error {{binary operator '==' cannot be applied to operands of type 'Any' and 'String?'}}
362366
// expected-note@-1 {{overloads for '==' exist with these partially matching parameter lists: (String, String)}}
363367
}

test/Constraints/iuo.swift

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,23 +216,30 @@ func conditionalDowncastToObject(b: B?) -> D {
216216
// expected-warning@-3 {{using '!' here is deprecated and will be removed in a future release}}
217217
}
218218

219+
// https://github.com/apple/swift/issues/49536
219220
// Ensure that we select the overload that does *not* involve forcing an IUO.
220-
func sr6988(x: Int?, y: Int?) -> Int { return x! }
221-
func sr6988(x: Int, y: Int) -> Float { return Float(x) }
221+
do {
222+
func f(x: Int?, y: Int?) -> Int { return x! }
223+
func f(x: Int, y: Int) -> Float { return Float(x) }
222224

223-
var x: Int! = nil
224-
var y: Int = 2
225+
let x: Int! = nil
226+
let y: Int = 2
225227

226-
let r = sr6988(x: x, y: y)
227-
let _: Int = r
228+
let r = f(x: x, y: y)
229+
let _: Int = r
230+
}
228231

229-
// SR-11998 / rdar://problem/58455441
230-
class C<T> {}
231-
var sub: C! = C<Int>()
232+
// rdar://problem/58455441
233+
// https://github.com/apple/swift/issues/54432
234+
do {
235+
class C<T> {}
236+
let _: C! = C<Int>()
237+
}
232238

233-
// SR-15219 (rdar://83352038): Make sure we don't crash if an IUO param becomes
234-
// a placeholder.
235-
func rdar83352038() {
239+
// rdar://problem/83352038
240+
// https://github.com/apple/swift/issues/57541
241+
// Make sure we don't crash if an IUO param becomes a placeholder.
242+
do {
236243
func foo(_: UnsafeRawPointer) -> Undefined {} // expected-error {{cannot find type 'Undefined' in scope}}
237244
let _ = { (cnode: AlsoUndefined!) -> UnsafeMutableRawPointer in // expected-error {{cannot find type 'AlsoUndefined' in scope}}
238245
return foo(cnode)

0 commit comments

Comments
 (0)