@@ -333,6 +333,55 @@ public struct GenNCWrapper<T : ~Copyable> : ~Copyable {
333333 }
334334}
335335
336+ public struct NCS : ~ Copyable {
337+ var _nc : NC
338+
339+ var nc : NC {
340+ borrow {
341+ return _nc
342+ }
343+ }
344+ }
345+
346+ public struct NCWrapper : ~ Copyable {
347+ var _nc : NC
348+ var _s : NCS
349+
350+ var nc : NC {
351+ borrow {
352+ return _nc
353+ }
354+ }
355+ var nested1 : NC {
356+ borrow {
357+ return _s. nc
358+ }
359+ }
360+
361+ var nested2 : NC {
362+ borrow {
363+ return nc
364+ }
365+ }
366+
367+ subscript( index: Int ) -> NC {
368+ borrow {
369+ return _nc
370+ }
371+ }
372+
373+ var nested_subscript : NC {
374+ borrow {
375+ return self [ 0 ]
376+ }
377+ }
378+
379+ var literal : Int {
380+ borrow {
381+ return 0
382+ }
383+ }
384+ }
336385
337386func test( ) {
338387 let w1 = Wrapper ( _k: Klass ( ) , _s: S ( _k: Klass ( ) ) )
@@ -451,3 +500,65 @@ func nctest() {
451500// CHECK: [[REG7:%.*]] = apply [[REG6]]<T>([[REG5]], [[REG0]]) : $@convention(method) <τ_0_0> (Int, @in_guaranteed GenWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0
452501// CHECK: return [[REG7]]
453502// CHECK: }
503+
504+ // CHECK-LABEL: sil hidden [ossa] @$s15borrow_accessor9NCWrapperV2ncAA2NCVvb : $@convention(method) (@guaranteed NCWrapper) -> @guaranteed NC {
505+ // CHECK: bb0([[REG0]] : @guaranteed $NCWrapper):
506+ // CHECK: [[REG1:%.*]] = copy_value [[REG0]]
507+ // CHECK: [[REG2:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG1]]
508+ // CHECK: [[REG4:%.*]] = begin_borrow [[REG2]]
509+ // CHECK: [[REG5:%.*]] = struct_extract [[REG0]], #NCWrapper._nc
510+ // CHECK: end_borrow [[REG4]]
511+ // CHECK: destroy_value [[REG2]]
512+ // CHECK: return [[REG5]]
513+ // CHECK: }
514+
515+ // CHECK-LABEL: sil hidden [ossa] @$s15borrow_accessor9NCWrapperV7nested1AA2NCVvb : $@convention(method) (@guaranteed NCWrapper) -> @guaranteed NC {
516+ // CHECK: bb0([[REG0]] : @guaranteed $NCWrapper):
517+ // CHECK: [[REG1:%.*]] = copy_value [[REG0]]
518+ // CHECK: [[REG2:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG1]]
519+ // CHECK: [[REG4:%.*]] = begin_borrow [[REG2]]
520+ // CHECK: [[REG5:%.*]] = struct_extract [[REG0]], #NCWrapper._s
521+ // CHECK: [[REG6:%.*]] = function_ref @$s15borrow_accessor3NCSV2ncAA2NCVvb : $@convention(method) (@guaranteed NCS) -> @guaranteed NC
522+ // CHECK: [[REG7:%.*]] = apply [[REG6]]([[REG5]]) : $@convention(method) (@guaranteed NCS) -> @guaranteed NC
523+ // CHECK: [[REG8:%.*]] = copy_value [[REG7]]
524+ // CHECK: [[REG9:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG8]]
525+ // CHECK: [[REG10:%.*]] = begin_borrow [[REG9]]
526+ // CHECK: end_borrow [[REG10]]
527+ // CHECK: destroy_value [[REG9]]
528+ // CHECK: end_borrow [[REG4]]
529+ // CHECK: destroy_value [[REG2]]
530+ // CHECK: return [[REG7]]
531+ // CHECK-LABEL: }
532+
533+ // CHECK-LABEL: sil hidden [ossa] @$s15borrow_accessor9NCWrapperVyAA2NCVSicib : $@convention(method) (Int, @guaranteed NCWrapper) -> @guaranteed NC {
534+ // CHECK: bb0([[REG0]] : $Int, [[REG1]] : @guaranteed $NCWrapper):
535+ // CHECK: [[REG3:%.*]] = copy_value [[REG1]]
536+ // CHECK: [[REG4:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG3]]
537+ // CHECK: [[REG6:%.*]] = begin_borrow [[REG4]]
538+ // CHECK: [[REG7:%.*]] = struct_extract [[REG1]], #NCWrapper._nc
539+ // CHECK: end_borrow [[REG6]]
540+ // CHECK: destroy_value [[REG4]]
541+ // CHECK: return [[REG7]]
542+ // CHECK: }
543+
544+ // CHECK-LABEL: sil hidden [ossa] @$s15borrow_accessor9NCWrapperV16nested_subscriptAA2NCVvb : $@convention(method) (@guaranteed NCWrapper) -> @guaranteed NC {
545+ // CHECK: bb0([[REG0]] : @guaranteed $NCWrapper):
546+ // CHECK: [[REG1:%.*]] = copy_value [[REG0]]
547+ // CHECK: [[REG2:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG1]]
548+ // CHECK: [[REG4:%.*]] = begin_borrow [[REG2]]
549+ // CHECK: [[REG5:%.*]] = integer_literal $Builtin.IntLiteral, 0
550+ // CHECK: [[REG6:%.*]] = metatype $@thin Int.Type
551+ // CHECK: [[REG7:%.*]] = function_ref @$sSi22_builtinIntegerLiteralSiBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int
552+ // CHECK: [[REG8:%.*]] = apply [[REG7]]([[REG5]], [[REG6]]) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int
553+ // CHECK: [[REG9:%.*]] = function_ref @$s15borrow_accessor9NCWrapperVyAA2NCVSicib : $@convention(method) (Int, @guaranteed NCWrapper) -> @guaranteed NC
554+ // CHECK: [[REG10:%.*]] = apply [[REG9]]([[REG8]], [[REG0]]) : $@convention(method) (Int, @guaranteed NCWrapper) -> @guaranteed NC
555+ // CHECK: [[REG11:%.*]] = copy_value [[REG10]]
556+ // CHECK: [[REG12:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG11]]
557+ // CHECK: [[REG13:%.*]] = begin_borrow [[REG12]]
558+ // CHECK: end_borrow [[REG13]]
559+ // CHECK: destroy_value [[REG12]]
560+ // CHECK: end_borrow [[REG4]]
561+ // CHECK: destroy_value [[REG2]]
562+ // CHECK: return [[REG10]]
563+ // CHECK: }
564+
0 commit comments