@@ -513,26 +513,24 @@ let closure = {
513
513
return helper
514
514
}
515
515
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 ) { }
518
519
519
- func id< T> ( _ x: T ) -> T {
520
- return x
521
- }
520
+ func id< T> ( _: T ) -> T { }
522
521
523
- var qux : ( ) -> Void = { }
522
+ let qux : ( ) -> Void
524
523
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')}}
527
526
528
- func forceUnwrap< T> ( _ x: T ? ) -> T {
529
- return x!
530
- }
527
+ func forceUnwrap< T> ( _: T ? ) -> T { }
531
528
532
- var qux1 : ( ( ) -> Void ) ? = { }
529
+ let qux1 : ( ( ) -> Void ) ?
533
530
534
- SR9839 ( qux1!)
535
- SR9839 ( forceUnwrap ( qux1) )
531
+ f ( qux1!)
532
+ f ( forceUnwrap ( qux1) )
533
+ }
536
534
537
535
// rdar://problem/65155671 - crash referencing parameter of outer closure
538
536
func rdar65155671( x: Int ) {
@@ -541,21 +539,22 @@ func rdar65155671(x: Int) {
541
539
} ( x)
542
540
}
543
541
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 ) { }
547
545
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
+ }
553
551
}
554
552
}
555
553
554
+ // https://github.com/apple/swift/issues/56501
556
555
// 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 {
559
558
func operation( ) { }
560
559
561
560
func test1( ) {
@@ -613,24 +612,25 @@ class SR14120 {
613
612
}
614
613
}
615
614
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 ) { }
620
618
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
+ }
624
623
}
625
- }
626
624
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
+ }
630
629
}
631
630
}
632
631
633
- // SR-13239
632
+ // https://github.com/apple/swift/issues/55680
633
+
634
634
func callit< T> ( _ f: ( ) -> T ) -> T {
635
635
f ( )
636
636
}
@@ -655,61 +655,61 @@ func callitVariadic<T>(_ fs: () -> T...) -> T {
655
655
fs. first!( )
656
656
}
657
657
658
- func testSR13239_Tuple ( ) -> Int {
658
+ func test_55680_Tuple ( ) -> Int {
659
659
// expected-error@+2{{conflicting arguments to generic parameter 'T' ('()' vs. 'Int')}}
660
660
// expected-note@+1:3{{generic parameter 'T' inferred as 'Int' from context}}
661
661
callitTuple ( 1 ) { // expected-note@:18{{generic parameter 'T' inferred as '()' from closure return expression}}
662
662
( print ( " hello " ) , 0 )
663
663
}
664
664
}
665
665
666
- func testSR13239 ( ) -> Int {
666
+ func test_55680 ( ) -> Int {
667
667
// expected-error@+2{{conflicting arguments to generic parameter 'T' ('()' vs. 'Int')}}
668
668
// expected-note@+1:3{{generic parameter 'T' inferred as 'Int' from context}}
669
669
callit { // expected-note@:10{{generic parameter 'T' inferred as '()' from closure return expression}}
670
670
print ( " hello " )
671
671
}
672
672
}
673
673
674
- func testSR13239_Args ( ) -> Int {
674
+ func test_55680_Args ( ) -> Int {
675
675
// expected-error@+2{{conflicting arguments to generic parameter 'T' ('()' vs. 'Int')}}
676
676
// expected-note@+1:3{{generic parameter 'T' inferred as 'Int' from context}}
677
677
callitArgs ( 1 ) { // expected-note@:17{{generic parameter 'T' inferred as '()' from closure return expression}}
678
678
print ( " hello " )
679
679
}
680
680
}
681
681
682
- func testSR13239_ArgsFn ( ) -> Int {
682
+ func test_55680_ArgsFn ( ) -> Int {
683
683
// expected-error@+2{{conflicting arguments to generic parameter 'T' ('()' vs. 'Int')}}
684
684
// expected-note@+1:3{{generic parameter 'T' inferred as 'Int' from context}}
685
685
callitArgsFn ( 1 ) { // expected-note@:19{{generic parameter 'T' inferred as '()' from closure return expression}}
686
686
{ print ( " hello " ) }
687
687
}
688
688
}
689
689
690
- func testSR13239MultiExpr ( ) -> Int {
690
+ func test_55680_MultiExpr ( ) -> Int {
691
691
callit {
692
692
print ( " hello " )
693
693
return print ( " hello " ) // expected-error {{cannot convert return expression of type '()' to return type 'Int'}}
694
694
}
695
695
}
696
696
697
- func testSR13239_GenericArg ( ) -> Int {
697
+ func test_55680_GenericArg ( ) -> Int {
698
698
// Generic argument is inferred as Int from first argument literal, so no conflict in this case.
699
699
callitGenericArg ( 1 ) {
700
700
print ( " hello " ) // expected-error {{cannot convert value of type '()' to closure result type 'Int'}}
701
701
}
702
702
}
703
703
704
- func testSR13239_Variadic ( ) -> Int {
704
+ func test_55680_Variadic ( ) -> Int {
705
705
// expected-error@+2{{conflicting arguments to generic parameter 'T' ('()' vs. 'Int')}}
706
706
// expected-note@+1:3{{generic parameter 'T' inferred as 'Int' from context}}
707
707
callitVariadic ( { // expected-note@:18{{generic parameter 'T' inferred as '()' from closure return expression}}
708
708
print ( " hello " )
709
709
} )
710
710
}
711
711
712
- func testSR13239_Variadic_Twos ( ) -> Int {
712
+ func test_55680_Variadic_Twos ( ) -> Int {
713
713
// expected-error@+1{{cannot convert return expression of type '()' to return type 'Int'}}
714
714
callitVariadic ( {
715
715
print ( " hello " )
0 commit comments