File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 4
4
5
5
// REQUIRES: asserts
6
6
7
+ class NSObject { }
8
+
7
9
struct TestInit {
8
10
var x : Int
9
11
var y : Int
@@ -479,3 +481,31 @@ func test_assignments() {
479
481
}
480
482
}
481
483
}
484
+
485
+ // rdar://112417250 (Crash with macro expansion on generic NSObject subclass)
486
+ // self is already borrowed within the initializer.
487
+ //
488
+ // CHECK-LABEL: sil private [ossa] @$s14init_accessors8testObjCyyF07GenericD9CSubclassL_CyADyxGxcfc : $@convention(method) <T> (@in T, @owned GenericObjCSubclass<T>) -> @owned GenericObjCSubclass<T> {
489
+ // CHECK: [[BORROW:%.*]] = load_borrow %{{.*}} : $*GenericObjCSubclass<T>
490
+ // CHECK: ref_element_addr [[BORROW]] : $GenericObjCSubclass<T>, #<abstract function>GenericObjCSubclass._value
491
+ // CHECK: apply
492
+ // CHECK: end_borrow [[BORROW]] : $GenericObjCSubclass<T>
493
+ // CHECK-NOT: end_borrow [[BORROW]] : $GenericObjCSubclass<T>
494
+ func testObjC( ) {
495
+ class GenericObjCSubclass < T> : NSObject {
496
+ var _value : T
497
+
498
+ var value : T {
499
+ @storageRestrictions ( initializes: _value)
500
+ init {
501
+ self . _value = newValue
502
+ }
503
+ get { _value }
504
+ set { _value = newValue }
505
+ }
506
+
507
+ init ( _ value: T ) {
508
+ self . value = value
509
+ }
510
+ }
511
+ }
You can’t perform that action at this time.
0 commit comments