Skip to content

Commit 70d784b

Browse files
Add compatibility tests for implicit (un)tupling in patterns (SR-11212).
1 parent 3fdb42f commit 70d784b

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

test/Sema/exhaustive_switch.swift

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,3 +1175,94 @@ func sr10301_as(_ foo: SR10301<String,(Int,Error)>) {
11751175
return
11761176
}
11771177
}
1178+
1179+
// SR-11212 tests: Some of the tests here rely on compiler bugs related to
1180+
// implicit (un)tupling in patterns. When you add a warning for the erroneous
1181+
// cases, feel free to add expected notes as appropriate.
1182+
enum SR11212Tests {
1183+
1184+
enum Untupled {
1185+
case upair(Int, Int)
1186+
}
1187+
1188+
func sr11212_content_untupled_pattern_tupled(u: Untupled) -> (Int, Int) {
1189+
switch u {
1190+
case .upair((let x, let y)): return (x, y)
1191+
}
1192+
}
1193+
1194+
func sr11212_content_untupled_pattern_tupled_nested(u: Untupled) -> (Int, Int) {
1195+
switch u {
1196+
case .upair(let (x, y)): return (x, y)
1197+
}
1198+
}
1199+
1200+
func sr11212_content_untupled_pattern_untupled(u: Untupled) -> (Int, Int) {
1201+
switch u {
1202+
case .upair(let x, let y): return (x, y)
1203+
}
1204+
}
1205+
1206+
func sr11212_content_untupled_pattern_ambiguous(u: Untupled) -> (Int, Int) {
1207+
switch u {
1208+
case .upair(let u_): return u_
1209+
}
1210+
}
1211+
1212+
enum Tupled {
1213+
case tpair((Int, Int))
1214+
}
1215+
1216+
func sr11212_content_tupled_pattern_tupled(t: Tupled) -> (Int, Int) {
1217+
switch t {
1218+
case .tpair((let x, let y)): return (x, y)
1219+
}
1220+
}
1221+
1222+
func sr11212_content_tupled_pattern_tupled_nested(t: Tupled) -> (Int, Int) {
1223+
switch t {
1224+
case .tpair(let (x, y)): return (x, y)
1225+
}
1226+
}
1227+
1228+
func sr11212_content_tupled_pattern_untupled(t: Tupled) -> (Int, Int) {
1229+
switch t {
1230+
case .tpair(let x, let y): return (x, y)
1231+
}
1232+
}
1233+
1234+
func sr11212_content_tupled_pattern_ambiguous(t: Tupled) -> (Int, Int) {
1235+
switch t {
1236+
case .tpair(let t_): return t_
1237+
}
1238+
}
1239+
1240+
enum Box<T> {
1241+
case box(T)
1242+
}
1243+
1244+
func sr11212_content_generic_pattern_tupled(b: Box<(Int, Int)>) -> (Int, Int) {
1245+
switch b {
1246+
case .box((let x, let y)): return (x, y)
1247+
}
1248+
}
1249+
1250+
func sr11212_content_generic_pattern_tupled_nested(b: Box<(Int, Int)>) -> (Int, Int) {
1251+
switch b {
1252+
case .box(let (x, y)): return (x, y)
1253+
}
1254+
}
1255+
1256+
func sr11212_content_generic_pattern_untupled(b: Box<(Int, Int)>) -> (Int, Int) {
1257+
switch b {
1258+
case .box(let x, let y): return (x, y)
1259+
}
1260+
}
1261+
1262+
func sr11212_content_generic_pattern_ambiguous(b: Box<(Int, Int)>) -> (Int, Int) {
1263+
switch b {
1264+
case .box(let b_): return b_
1265+
}
1266+
}
1267+
1268+
} // end SR11212Tests

0 commit comments

Comments
 (0)