File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -4019,6 +4019,9 @@ generateForEachStmtConstraints(
4019
4019
if (cs.generateConstraints (whereTarget, FreeTypeVariableBinding::Disallow))
4020
4020
return None;
4021
4021
4022
+ cs.setContextualType (forEachStmtInfo.whereExpr ,
4023
+ TypeLoc::withoutLoc (boolType), CTP_Condition);
4024
+
4022
4025
forEachStmtInfo.whereExpr = whereTarget.getAsExpr ();
4023
4026
}
4024
4027
Original file line number Diff line number Diff line change @@ -72,3 +72,16 @@ _ = p =*= &o
72
72
73
73
func rdar25963182( _ bytes: [ UInt8 ] = nil ) { }
74
74
// expected-error@-1 {{nil default argument value cannot be converted to type}}
75
+
76
+ // SR-13262
77
+ struct SR13262_S { }
78
+
79
+ func SR13262( _ x: Int ) { }
80
+ func SR13262_Int( _ x: Int ) -> Int { 0 }
81
+ func SR13262_SF( _ x: Int ) -> SR13262_S { SR13262_S ( ) }
82
+
83
+ func testSR13262( _ arr: [ Int ] ) {
84
+ for x in arr where SR13262 ( x) { } // expected-error {{cannot convert value of type '()' to expected condition type 'Bool'}}
85
+ for x in arr where SR13262_Int ( x) { } // expected-error {{type 'Int' cannot be used as a boolean; test for '!= 0' instead}} {{22-22=(}} {{36-36= != 0)}}
86
+ for x in arr where SR13262_SF ( x) { } // expected-error {{cannot convert value of type 'SR13262_S' to expected condition type 'Bool'}}
87
+ }
You can’t perform that action at this time.
0 commit comments