@@ -445,28 +445,36 @@ func testEnumLValue(s: inout StructOfEnum) {
445
445
enumLValueHelper ( & s. e, & s. f)
446
446
}
447
447
448
+ struct MyDict < K: Hashable , V> {
449
+ let s = " " // make this non-trivial
450
+ subscript( key: K ) -> V ? {
451
+ get { return nil }
452
+ set { }
453
+ }
454
+ }
455
+
448
456
// --- Optional access.
449
- func accessOptionalArray( _ dict : [ Int : [ Int ] ] = [ : ] ) {
457
+ func accessOptionalArray( _ dict : MyDict < Int , [ Int ] > ) {
450
458
var dict = dict
451
459
dict [ 1 ] ? . append ( 2 )
452
460
}
453
- // CHECK-LABEL: sil hidden @$S20access_marker_verify0A13OptionalArrayyySDySiSaySiGGF : $@convention(thin) (@guaranteed Dictionary <Int, Array<Int>>) -> () {
454
- // CHECK: bb0(%0 : @guaranteed $Dictionary <Int, Array<Int>>):
455
- // CHECK: alloc_box ${ var Dictionary <Int, Array<Int>> }, var, name "dict"
461
+ // CHECK-LABEL: sil hidden @$S20access_marker_verify0A13OptionalArrayyyAA6MyDictVySiSaySiGGF : $@convention(thin) (@guaranteed MyDict <Int, Array<Int>>) -> () {
462
+ // CHECK: bb0(%0 : @guaranteed $MyDict <Int, Array<Int>>):
463
+ // CHECK: alloc_box ${ var MyDict <Int, Array<Int>> }, var, name "dict"
456
464
// CHECK: [[PROJ:%.*]] = project_box
457
465
// ----- initialize the box.
458
466
// CHECK: [[INITACCESS:%.*]] = begin_access [modify] [unsafe] [[PROJ]]
459
467
// CHECK: store %{{.*}} to [init] [[INITACCESS]]
460
468
// CHECK: end_access [[INITACCESS]]
461
- // ----- begin formal access for Dictionary .subscript.setter
469
+ // ----- begin formal access for MyDict .subscript.setter
462
470
// CHECK: [[BOXACCESS:%.*]] = begin_access [modify] [unknown] [[PROJ]]
463
471
// CHECK: [[TEMP:%.*]] = alloc_stack $Optional<Array<Int>>
464
- // CHECK: load_borrow [[BOXACCESS]] : $*Dictionary <Int, Array<Int>>
472
+ // CHECK: load_borrow [[BOXACCESS]] : $*MyDict <Int, Array<Int>>
465
473
// ----- Initialize some trivial temporaries.
466
474
// CHECK: alloc_stack $Int
467
475
// CHECK-NOT: begin_access
468
476
// CHECK: store %{{.*}} to [trivial]
469
- // ----- Call Dictionary .subscript.getter.
477
+ // ----- Call MyDict .subscript.getter.
470
478
// CHECK-NOT: begin_access
471
479
// CHECK: apply %{{.*}}<Int, [Int]>
472
480
// ----- access the temporary array result of the getter
@@ -482,10 +490,10 @@ func accessOptionalArray(_ dict : [Int : [Int]] = [:]) {
482
490
// CHECK: [[TEMP3:%.*]] = alloc_stack $Int
483
491
// CHECK-NOT: begin_access
484
492
// CHECK: store %{{.*}} to [trivial] [[TEMP3]] : $*Int
485
- // Call Dictionary .subscript.setter
486
- // CHECK: apply %{{.*}}<Int, [Int]>([[WRITEBACK]], [[TEMP3]], [[BOXACCESS]]) : $@convention(method) <τ_0_0, τ_0_1 where τ_0_0 : Hashable> (@in Optional<τ_0_1>, @in τ_0_0, @inout Dictionary <τ_0_0, τ_0_1>) -> ()
493
+ // Call MyDict .subscript.setter
494
+ // CHECK: apply %{{.*}}<Int, [Int]>([[WRITEBACK]], [[TEMP3]], [[BOXACCESS]]) : $@convention(method) <τ_0_0, τ_0_1 where τ_0_0 : Hashable> (@in Optional<τ_0_1>, @in τ_0_0, @inout MyDict <τ_0_0, τ_0_1>) -> ()
487
495
// CHECK: end_access [[TEMPACCESS]] : $*Optional<Array<Int>>
488
- // CHECK: end_access [[BOXACCESS]] : $*Dictionary <Int, Array<Int>>
496
+ // CHECK: end_access [[BOXACCESS]] : $*MyDict <Int, Array<Int>>
489
497
// CHECK: br
490
498
//
491
499
// CHECK: bb2:
@@ -501,9 +509,9 @@ func accessOptionalArray(_ dict : [Int : [Int]] = [:]) {
501
509
// CHECK: store [[TEMPARRAYVAL]] to [init] [[ARRAYCOPY]] : $*Optional<Array<Int>>
502
510
// CHECK: alloc_stack $Int
503
511
// CHECK: store %{{.*}} to [trivial]
504
- // ----- call Dictionary .subscript.setter
505
- // CHECK: apply %{{.*}}<Int, [Int]>([[ARRAYCOPY]], %{{.*}}, [[BOXACCESS]]) : $@convention(method) <τ_0_0, τ_0_1 where τ_0_0 : Hashable> (@in Optional<τ_0_1>, @in τ_0_0, @inout Dictionary <τ_0_0, τ_0_1>) -> ()
506
- // CHECK-LABEL: } // end sil function '$S20access_marker_verify0A13OptionalArrayyySDySiSaySiGGF '
512
+ // ----- call MyDict .subscript.setter
513
+ // CHECK: apply %{{.*}}<Int, [Int]>([[ARRAYCOPY]], %{{.*}}, [[BOXACCESS]]) : $@convention(method) <τ_0_0, τ_0_1 where τ_0_0 : Hashable> (@in Optional<τ_0_1>, @in τ_0_0, @inout MyDict <τ_0_0, τ_0_1>) -> ()
514
+ // CHECK-LABEL: } // end sil function '$S20access_marker_verify0A13OptionalArrayyyAA6MyDictVySiSaySiGGF '
507
515
508
516
// --- Optional map.
509
517
enum OptionalWithMap < Wrapped> {
0 commit comments