Skip to content

Commit 256d47a

Browse files
authored
Merge pull request #22874 from gottesmm/pr-d3d267ddaa99f7051c928b38b7099b85a660c725
Add the SILGenPattern test case from SR-6664 even though I already fi…
2 parents 0e4f95e + a49e3ad commit 256d47a

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

test/SILGen/switch.swift

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ func test_isa_1(p: P) {
310310
a()
311311
// CHECK: function_ref @$s6switch1ayyF
312312
// CHECK: br [[CONT:bb[0-9]+]]
313-
313+
314314
// CHECK: [[IS_NOT_X]]:
315315
// CHECK: checked_cast_addr_br copy_on_success P in [[P]] : $*P to Y in {{%.*}} : $*Y, [[IS_Y:bb[0-9]+]], [[IS_NOT_Y:bb[0-9]+]]
316316

@@ -524,7 +524,7 @@ func test_isa_class_2(x: B) -> AnyObject {
524524
// CHECK: [[NO_CASE1]]:
525525
// CHECK: destroy_value [[CAST_D1_COPY]]
526526
// CHECK: br [[NEXT_CASE:bb5]]
527-
527+
528528
// CHECK: [[IS_NOT_D1]]([[NOCAST_D1:%.*]] : @guaranteed $B):
529529
// CHECK: end_borrow [[NOCAST_D1]]
530530
// CHECK: br [[NEXT_CASE]]
@@ -1020,7 +1020,7 @@ func testOptionalEnumMixWithNil(_ a : Int?) -> Int {
10201020
// CHECK-LABEL: sil hidden [ossa] @$s6switch43testMultiPatternsWithOuterScopeSameNamedVar4base6filterySiSg_AEtF
10211021
func testMultiPatternsWithOuterScopeSameNamedVar(base: Int?, filter: Int?) {
10221022
switch(base, filter) {
1023-
1023+
10241024
case (.some(let base), .some(let filter)):
10251025
// CHECK: bb2(%10 : $Int):
10261026
// CHECK-NEXT: debug_value %8 : $Int, let, name "base"
@@ -1034,7 +1034,7 @@ func testMultiPatternsWithOuterScopeSameNamedVar(base: Int?, filter: Int?) {
10341034
// CHECK: bb5([[OTHER_BASE:%.*]] : $Int)
10351035
// CHECK-NEXT: debug_value [[OTHER_BASE]] : $Int, let, name "base"
10361036
// CHECK-NEXT: br bb6([[OTHER_BASE]] : $Int)
1037-
1037+
10381038
// CHECK: bb6([[ARG:%.*]] : $Int):
10391039
print("single: \(base)")
10401040
default:
@@ -1261,3 +1261,27 @@ func partial_address_only_tuple_dispatch_with_fail_case(_ name: Klass, _ value:
12611261
break
12621262
}
12631263
}
1264+
1265+
// This was crashing the ownership verifier at some point and was reported in
1266+
// SR-6664. Just make sure that we still pass the ownership verifier.
1267+
1268+
// `indirect` is necessary; generic parameter is necessary.
1269+
indirect enum SR6664_Base<Element> {
1270+
// Tuple associated value is necessary; one element must be a function,
1271+
// the other must be a non-function using the generic parameter.
1272+
// (The original associated value was `(where: (Element) -> Bool, of: Element?)`,
1273+
// to give you an idea of the variety of types.)
1274+
case index((Int) -> Void, Element)
1275+
1276+
// Function can be in an extension or not. Can have a return value or not. Can
1277+
// have a parameter or not. Can be generic or not.
1278+
func relative() {
1279+
switch self {
1280+
// Matching the case is necessary. You can capture or ignore the associated
1281+
// values.
1282+
case .index:
1283+
// Body doesn't matter.
1284+
break
1285+
}
1286+
}
1287+
}

0 commit comments

Comments
 (0)