@@ -78,7 +78,7 @@ struct TupleBuilderWithoutIf { // expected-note 3{{struct 'TupleBuilderWithoutIf
78
78
static func buildDo< T> ( _ value: T ) -> T { return value }
79
79
}
80
80
81
- func tuplify< T> ( _ cond: Bool , @TupleBuilder body: ( Bool ) -> T ) { // expected-note {{in call to function 'tuplify(_:body:)'}}
81
+ func tuplify< T> ( _ cond: Bool , @TupleBuilder body: ( Bool ) -> T ) {
82
82
print ( body ( cond) )
83
83
}
84
84
@@ -194,7 +194,7 @@ struct TupleP<U> : P {
194
194
195
195
@resultBuilder
196
196
struct Builder {
197
- static func buildBlock< S0, S1> ( _ stmt1: S0 , _ stmt2: S1 ) // expected-note {{required by static method 'buildBlock' where 'S1' = 'Label<_>.Type'}}
197
+ static func buildBlock< S0, S1> ( _ stmt1: S0 , _ stmt2: S1 )
198
198
-> TupleP < ( S0 , S1 ) > where S0: P , S1: P {
199
199
return TupleP ( ( stmt1, stmt2) )
200
200
}
@@ -216,7 +216,7 @@ struct Label<L> : P where L : P { // expected-note 2 {{'L' declared as parameter
216
216
}
217
217
218
218
func test_51167632( ) -> some P {
219
- AnyP ( G { // expected-error {{type 'Label<_>.Type' cannot conform to 'P'}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}}
219
+ AnyP ( G {
220
220
Text ( " hello " )
221
221
Label // expected-error {{generic parameter 'L' could not be inferred}}
222
222
// expected-note@-1 {{explicitly specify the generic arguments to fix this issue}} {{10-10=<<#L: P#>>}}
@@ -509,7 +509,7 @@ enum E3 {
509
509
}
510
510
511
511
func testCaseMutabilityMismatches( e: E3 ) {
512
- tuplify ( true ) { c in // expected-error {{generic parameter 'T' could not be inferred}}
512
+ tuplify ( true ) { c in
513
513
" testSwitch "
514
514
switch e {
515
515
case . a( let x, var y) ,
@@ -527,12 +527,13 @@ func testCaseMutabilityMismatches(e: E3) {
527
527
528
528
// Check for type equivalence among different case variables with the same name.
529
529
func testCaseVarTypes( e: E3 ) {
530
- // FIXME: Terrible diagnostic
531
- tuplify ( true ) { c in // expected-error{{type of expression is ambiguous without more context}}
530
+ tuplify ( true ) { c in
532
531
" testSwitch "
533
532
switch e {
534
533
case . a( let x, let y) ,
535
534
. c( let x, let y) :
535
+ // expected-error@-1 {{pattern variable bound to type 'String', expected type 'Int'}}
536
+ // expected-error@-2 {{pattern variable bound to type 'Int', expected type 'String'}}
536
537
x
537
538
y + " a "
538
539
}
@@ -659,14 +660,16 @@ struct MyView {
659
660
}
660
661
661
662
@TupleBuilder var invalidCaseWithoutDot : some P {
663
+ // expected-error@-1 {{return type of property 'invalidCaseWithoutDot' requires that 'Either<Int, Int>' conform to 'P'}}
664
+ // expected-note@-2 {{opaque return type declared here}}
662
665
switch Optional . some ( 1 ) {
663
666
case none: 42 // expected-error {{cannot find 'none' in scope}}
664
667
case . some( let x) :
665
668
0
666
669
}
667
670
}
668
671
669
- @TupleBuilder var invalidConversion : Int { // expected-error {{cannot convert value of type 'String' to specified type 'Int'}}
672
+ @TupleBuilder var invalidConversion : Int { // expected-error {{cannot convert return expression of type 'String' to return type 'Int'}}
670
673
" "
671
674
}
672
675
}
684
687
}
685
688
686
689
struct TuplifiedStructWithInvalidClosure {
687
- var condition : Bool
690
+ var condition : Bool ?
688
691
689
692
@TupleBuilder var unknownParameter : some Any {
690
693
if let cond = condition {
@@ -697,7 +700,7 @@ struct TuplifiedStructWithInvalidClosure {
697
700
}
698
701
699
702
@TupleBuilder var unknownResult : some Any {
700
- if let cond = condition {
703
+ if let _ = condition {
701
704
let _ = { ( ) -> UnknownType in // expected-error {{cannot find type 'UnknownType' in scope}}
702
705
}
703
706
42
@@ -707,7 +710,7 @@ struct TuplifiedStructWithInvalidClosure {
707
710
}
708
711
709
712
@TupleBuilder var multipleLevelsDeep : some Any {
710
- if let cond = condition {
713
+ if let _ = condition {
711
714
switch MyError . boom {
712
715
case . boom:
713
716
let _ = { ( ) -> UnknownType in // expected-error {{cannot find type 'UnknownType' in scope}}
@@ -721,7 +724,7 @@ struct TuplifiedStructWithInvalidClosure {
721
724
}
722
725
723
726
@TupleBuilder var errorsDiagnosedByParser : some Any {
724
- if let cond = condition {
727
+ if let _ = condition {
725
728
tuplify { _ in
726
729
self . // expected-error {{expected member name following '.'}}
727
730
}
@@ -759,9 +762,10 @@ func test_rdar65667992() {
759
762
var entry : E
760
763
761
764
@Builder var body : S {
762
- switch entry { // expected-error {{type 'E' has no member 'unset'}}
765
+ switch entry {
763
766
case . set( _, _) : S ( )
764
- case . unset( _) : S ( ) // expected-error {{'_' can only appear in a pattern or on the left side of an assignment}}
767
+ case . unset( _) : S ( ) // expected-error {{type 'E' has no member 'unset'}}
768
+ // expected-error@-1 {{'_' can only appear in a pattern or on the left side of an assignment}}
765
769
default : S ( )
766
770
}
767
771
}
@@ -796,7 +800,9 @@ func test_missing_member_in_optional_context() {
796
800
if let prop = test? . prop { // expected-error {{value of type 'Test' has no member 'prop'}}
797
801
0
798
802
}
803
+ }
799
804
805
+ tuplify ( true ) { c in
800
806
if let method = test? . method ( ) { // expected-error {{value of type 'Test' has no member 'method'}}
801
807
1
802
808
}
@@ -850,10 +856,10 @@ func test_invalid_result_is_diagnosed() {
850
856
}
851
857
}
852
858
853
- struct S < T> { } // expected-note {{arguments to generic parameter 'T' ('Int' and 'String') are expected to be equal}}
859
+ struct S < T> { }
854
860
855
861
@MyBuilder
856
- func test( ) -> S < String > { // expected-error {{cannot convert result builder result type 'S<Int>' to return type 'S<String>}}
862
+ func test( ) -> S < String > { // expected-error {{conflicting arguments to generic parameter 'T1' ( 'S<Int>' vs. 'S<String>') }}
857
863
S < Int > ( )
858
864
}
859
865
}
@@ -887,6 +893,15 @@ func test_associated_values_dont_block_solver_when_unresolved() {
887
893
// expected-note@-1 {{chain the optional using '?' to access member 'kind' only for non-'nil' base values}}
888
894
// expected-note@-2 {{force-unwrap using '!' to abort execution if the optional value contains 'nil'}}
889
895
896
+ switch v. kind {
897
+ case . a( _) : " a "
898
+ case . b: " b "
899
+ }
900
+ }
901
+
902
+ @Builder var switchError : String {
903
+ let v = container. prop!. kind
904
+
890
905
switch v. kind { // expected-error {{value of type 'Value.Kind' has no member 'kind'}}
891
906
case . a( _) : " a "
892
907
case . b: " b "
0 commit comments