Skip to content

Commit 6c615c8

Browse files
committed
Gardening: Migrate test suite to GH issues: expr/closure
1 parent 5324bf9 commit 6c615c8

File tree

6 files changed

+78
-75
lines changed

6 files changed

+78
-75
lines changed

test/expr/closure/closures.swift

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -513,26 +513,24 @@ let closure = {
513513
return helper
514514
}
515515

516-
// SR-9839
517-
func SR9839(_ x: @escaping @convention(block) () -> Void) {}
516+
// https://github.com/apple/swift/issues/52253
517+
do {
518+
func f(_: @escaping @convention(block) () -> Void) {}
518519

519-
func id<T>(_ x: T) -> T {
520-
return x
521-
}
520+
func id<T>(_: T) -> T {}
522521

523-
var qux: () -> Void = {}
522+
let qux: () -> Void
524523

525-
SR9839(qux)
526-
SR9839(id(qux)) // expected-error {{conflicting arguments to generic parameter 'T' ('() -> Void' vs. '@convention(block) () -> Void')}}
524+
f(qux)
525+
f(id(qux)) // expected-error {{conflicting arguments to generic parameter 'T' ('() -> Void' vs. '@convention(block) () -> Void')}}
527526

528-
func forceUnwrap<T>(_ x: T?) -> T {
529-
return x!
530-
}
527+
func forceUnwrap<T>(_: T?) -> T {}
531528

532-
var qux1: (() -> Void)? = {}
529+
let qux1: (() -> Void)?
533530

534-
SR9839(qux1!)
535-
SR9839(forceUnwrap(qux1))
531+
f(qux1!)
532+
f(forceUnwrap(qux1))
533+
}
536534

537535
// rdar://problem/65155671 - crash referencing parameter of outer closure
538536
func rdar65155671(x: Int) {
@@ -541,21 +539,22 @@ func rdar65155671(x: Int) {
541539
}(x)
542540
}
543541

544-
func sr3186<T, U>(_ f: (@escaping (@escaping (T) -> U) -> ((T) -> U))) -> ((T) -> U) {
545-
return { x in return f(sr3186(f))(x) }
546-
}
542+
// https://github.com/apple/swift/issues/45774
543+
do {
544+
func f<T, U>(_: (@escaping (@escaping (T) -> U) -> ((T) -> U))) -> ((T) -> U) {}
547545

548-
class SR3186 {
549-
init() {
550-
// expected-warning@+1{{capture 'self' was never used}}
551-
let v = sr3186 { f in { [unowned self, f] x in x != 1000 ? f(x + 1) : "success" } }(0)
552-
print("\(v)")
546+
class C {
547+
init() {
548+
// expected-warning@+1{{capture 'self' was never used}}
549+
let _ = f { fn in { [unowned self, fn] x in x != 1000 ? fn(x + 1) : "success" } }(0)
550+
}
553551
}
554552
}
555553

554+
// https://github.com/apple/swift/issues/56501
556555
// Apply the explicit 'self' rule even if it refers to a capture, if
557-
// we're inside a nested closure
558-
class SR14120 {
556+
// we're inside a nested closure.
557+
class C_56501 {
559558
func operation() {}
560559

561560
func test1() {
@@ -613,24 +612,25 @@ class SR14120 {
613612
}
614613
}
615614

616-
// SR-14678
617-
func call<T>(_ : Int, _ f: () -> (T, Int)) -> (T, Int) {
618-
f()
619-
}
615+
// https://github.com/apple/swift/issues/57029
616+
do {
617+
func call<T>(_ : Int, _ f: () -> (T, Int)) -> (T, Int) {}
620618

621-
func testSR14678() -> (Int, Int) {
622-
call(1) { // expected-error {{cannot convert return expression of type '((), Int)' to return type '(Int, Int)'}}
623-
(print("hello"), 0)
619+
func f() -> (Int, Int) {
620+
call(1) { // expected-error {{cannot convert return expression of type '((), Int)' to return type '(Int, Int)'}}
621+
((), 0)
622+
}
624623
}
625-
}
626624

627-
func testSR14678_Optional() -> (Int, Int)? {
628-
call(1) { // expected-error {{cannot convert return expression of type '((), Int)' to return type '(Int, Int)'}}
629-
(print("hello"), 0)
625+
func f_Optional() -> (Int, Int)? {
626+
call(1) { // expected-error {{cannot convert return expression of type '((), Int)' to return type '(Int, Int)'}}
627+
((), 0)
628+
}
630629
}
631630
}
632631

633-
// SR-13239
632+
// https://github.com/apple/swift/issues/55680
633+
634634
func callit<T>(_ f: () -> T) -> T {
635635
f()
636636
}
@@ -655,61 +655,61 @@ func callitVariadic<T>(_ fs: () -> T...) -> T {
655655
fs.first!()
656656
}
657657

658-
func testSR13239_Tuple() -> Int {
658+
func test_55680_Tuple() -> Int {
659659
// expected-error@+2{{conflicting arguments to generic parameter 'T' ('()' vs. 'Int')}}
660660
// expected-note@+1:3{{generic parameter 'T' inferred as 'Int' from context}}
661661
callitTuple(1) { // expected-note@:18{{generic parameter 'T' inferred as '()' from closure return expression}}
662662
(print("hello"), 0)
663663
}
664664
}
665665

666-
func testSR13239() -> Int {
666+
func test_55680() -> Int {
667667
// expected-error@+2{{conflicting arguments to generic parameter 'T' ('()' vs. 'Int')}}
668668
// expected-note@+1:3{{generic parameter 'T' inferred as 'Int' from context}}
669669
callit { // expected-note@:10{{generic parameter 'T' inferred as '()' from closure return expression}}
670670
print("hello")
671671
}
672672
}
673673

674-
func testSR13239_Args() -> Int {
674+
func test_55680_Args() -> Int {
675675
// expected-error@+2{{conflicting arguments to generic parameter 'T' ('()' vs. 'Int')}}
676676
// expected-note@+1:3{{generic parameter 'T' inferred as 'Int' from context}}
677677
callitArgs(1) { // expected-note@:17{{generic parameter 'T' inferred as '()' from closure return expression}}
678678
print("hello")
679679
}
680680
}
681681

682-
func testSR13239_ArgsFn() -> Int {
682+
func test_55680_ArgsFn() -> Int {
683683
// expected-error@+2{{conflicting arguments to generic parameter 'T' ('()' vs. 'Int')}}
684684
// expected-note@+1:3{{generic parameter 'T' inferred as 'Int' from context}}
685685
callitArgsFn(1) { // expected-note@:19{{generic parameter 'T' inferred as '()' from closure return expression}}
686686
{ print("hello") }
687687
}
688688
}
689689

690-
func testSR13239MultiExpr() -> Int {
690+
func test_55680_MultiExpr() -> Int {
691691
callit {
692692
print("hello")
693693
return print("hello") // expected-error {{cannot convert return expression of type '()' to return type 'Int'}}
694694
}
695695
}
696696

697-
func testSR13239_GenericArg() -> Int {
697+
func test_55680_GenericArg() -> Int {
698698
// Generic argument is inferred as Int from first argument literal, so no conflict in this case.
699699
callitGenericArg(1) {
700700
print("hello") // expected-error {{cannot convert value of type '()' to closure result type 'Int'}}
701701
}
702702
}
703703

704-
func testSR13239_Variadic() -> Int {
704+
func test_55680_Variadic() -> Int {
705705
// expected-error@+2{{conflicting arguments to generic parameter 'T' ('()' vs. 'Int')}}
706706
// expected-note@+1:3{{generic parameter 'T' inferred as 'Int' from context}}
707707
callitVariadic({ // expected-note@:18{{generic parameter 'T' inferred as '()' from closure return expression}}
708708
print("hello")
709709
})
710710
}
711711

712-
func testSR13239_Variadic_Twos() -> Int {
712+
func test_55680_Variadic_Twos() -> Int {
713713
// expected-error@+1{{cannot convert return expression of type '()' to return type 'Int'}}
714714
callitVariadic({
715715
print("hello")

test/expr/closure/closures_swift6.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ class ExplicitSelfRequiredTest {
1212
}
1313
}
1414

15-
class SR14120 {
15+
// https://github.com/apple/swift/issues/56501
16+
class C_56501 {
1617
func operation() {}
1718

1819
func test1() {

test/expr/closure/inference.swift

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -38,43 +38,42 @@ var nestedClosuresWithBrokenInference = { f: Int in {} }
3838
// expected-error@-2 {{expected expression}}
3939
// expected-error@-3 {{cannot find 'f' in scope}}
4040

41-
// SR-11540
42-
43-
func SR11540<R>(action: () -> R) -> Void {}
44-
45-
func SR11540<T, R>(action: (T) -> R) -> Void {}
41+
// https://github.com/apple/swift/issues/53941
42+
do {
43+
func f1<R>(action: () -> R) -> Void {}
4644

47-
func SR11540_1<T, R>(action: (T) -> R) -> Void {}
45+
func f1<T, R>(action: (T) -> R) -> Void {}
4846

49-
SR11540(action: { return }) // Ok SR11540<R>(action: () -> R) was the selected overload.
47+
func f2<T, R>(action: (T) -> R) -> Void {}
5048

51-
// In case that's the only possible overload, it's acceptable
52-
SR11540_1(action: { return }) // OK
49+
f1(action: { return }) // Ok f1<R>(action: () -> R) was the selected overload.
5350

54-
// SR-8563
55-
func SR8563<A,Z>(_ f: @escaping (A) -> Z) -> (A) -> Z {
56-
return f
51+
// In case that's the only possible overload, it's acceptable
52+
f2(action: { return }) // OK
5753
}
5854

59-
func SR8563<A,B,Z>(_ f: @escaping (A, B) -> Z) -> (A, B) -> Z {
60-
return f
61-
}
55+
// https://github.com/apple/swift/issues/51081
56+
do {
57+
func f1<A,Z>(_ f: @escaping (A) -> Z) -> (A) -> Z {}
58+
59+
func f1<A,B,Z>(_ f: @escaping (A, B) -> Z) -> (A, B) -> Z {}
6260

63-
let aa = SR8563 { (a: Int) in }
64-
let bb = SR8563 { (a1: Int, a2: String) in } // expected-note {{'bb' declared here}}
61+
let aa = f1 { (a: Int) in }
62+
let bb = f1 { (a1: Int, a2: String) in } // expected-note {{'bb' declared here}}
6563

66-
aa(1) // Ok
67-
bb(1, "2") // Ok
68-
bb(1) // expected-error {{missing argument for parameter #2 in call}}
64+
aa(1) // Ok
65+
bb(1, "2") // Ok
66+
bb(1) // expected-error {{missing argument for parameter #2 in call}}
6967

70-
// Tuple
71-
let cc = SR8563 { (_: (Int)) in }
68+
// Tuple
69+
let cc = f1 { (_: (Int)) in }
7270

73-
cc((1)) // Ok
74-
cc(1) // Ok
71+
cc((1)) // Ok
72+
cc(1) // Ok
73+
}
7574

76-
// SR-12955
77-
func SR12955() {
75+
// https://github.com/apple/swift/issues/55401
76+
do {
7877
let f: @convention(c) (T) -> Void // expected-error {{cannot find type 'T' in scope}}
7978
}
8079

test/expr/closure/single_expr.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ let backupPlan: () -> Int = { haltAndCatchFire() }
100100
func missionCritical(storage: () -> String) {}
101101
missionCritical(storage: { haltAndCatchFire() })
102102

103-
// <https://bugs.swift.org/browse/SR-4963>
103+
// https://github.com/apple/swift/issues/47540
104104
enum E { }
105105
func takesAnotherUninhabitedType(e: () -> E) {}
106106
takesAnotherUninhabitedType { haltAndCatchFire() }

test/expr/closure/single_expr_ifdecl.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ missionCritical(storage: {
177177
#endif
178178
})
179179

180-
// <https://bugs.swift.org/browse/SR-4963>
180+
// https://github.com/apple/swift/issues/47540
181181
enum E { }
182182
func takesAnotherUninhabitedType(e: () -> E) {}
183183
takesAnotherUninhabitedType {

test/expr/closure/trailing.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ func notPostfix() {
3939
}
4040

4141
func notLiterals() {
42-
struct SR3671 { // <https://bugs.swift.org/browse/SR-3671>
42+
// https://github.com/apple/swift/issues/46256
43+
struct S {
4344
var v: Int = 1 { // expected-error {{variable with getter/setter cannot have an initial value}}
4445
get {
4546
return self.v
@@ -218,10 +219,12 @@ func r23036383(foo: Foo23036383?, obj: Foo23036383) {
218219
if let _ = (foo?.map {$0+1}.map({$0+1})).map({$0+1}) {} // OK
219220
}
220221

222+
// https://github.com/apple/swift/issues/51245
223+
221224
func id<T>(fn: () -> T) -> T { return fn() }
222225
func any<T>(fn: () -> T) -> Any { return fn() }
223226

224-
func testSR8736() {
227+
func test_51245() {
225228
if !id { true } { return } // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
226229

227230
if id { true } == true { return } // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}

0 commit comments

Comments
 (0)