1- // RUN: %target-swift-frontend %s -emit-sil -enable-builtin-module \
2- // RUN: -Xllvm -disable-lifetime-dependence-diagnostics \
3- // RUN: -enable-experimental-feature NonescapableTypes \
4- // RUN: -disable-experimental-parser-round-trip \
5- // RUN: -enable-experimental-feature NoncopyableGenerics \
6- // RUN: | %FileCheck %s
7-
1+ // RUN: %target-swift-frontend %s \
2+ // RUN: -emit-sil \
3+ // RUN: -enable-builtin-module \
4+ // RUN: -Xllvm -disable-lifetime-dependence-diagnostics \
5+ // RUN: -enable-experimental-feature NonescapableTypes \
6+ // RUN: -disable-experimental-parser-round-trip \
7+ // RUN: -enable-experimental-feature NoncopyableGenerics \
8+ // RUN: -enable-experimental-lifetime-dependence-inference | %FileCheck %s
89// REQUIRES: asserts
910
1011import Builtin
1112
1213struct BufferView : ~ Escapable {
1314 let ptr : UnsafeRawBufferPointer
15+ @_unsafeNonescapableResult
1416 init ( _ ptr: UnsafeRawBufferPointer ) {
1517 self . ptr = ptr
1618 }
19+ // CHECK-LABEL: sil hidden @$s28implicit_lifetime_dependence10BufferViewVyA2ChcfC : $@convention(method) (@guaranteed BufferView, @thin BufferView.Type) -> _borrow(1) @owned BufferView {
20+ init ( _ otherBV: borrowing BufferView ) {
21+ self . ptr = otherBV. ptr
22+ }
23+ // CHECK-LABEL: sil hidden @$s28implicit_lifetime_dependence10BufferViewVyA2CcfC : $@convention(method) (@owned BufferView, @thin BufferView.Type) -> _inherit(1) @owned BufferView {
24+ init ( _ otherBV: consuming BufferView ) {
25+ self . ptr = otherBV. ptr
26+ }
1727}
1828
1929struct MutableBufferView : ~ Escapable, ~ Copyable {
2030 let ptr : UnsafeMutableRawBufferPointer
31+ @_unsafeNonescapableResult
2132 init ( _ ptr: UnsafeMutableRawBufferPointer ) {
2233 self . ptr = ptr
2334 }
2435}
2536
37+ /*
38+ // rdar://121983770
2639func testBasic() {
2740 let capacity = 4
2841 let a = Array(0..<capacity)
@@ -33,6 +46,7 @@ func testBasic() {
3346 use(newView)
3447 }
3548}
49+ */
3650
3751// CHECK-LABEL: sil hidden @$s28implicit_lifetime_dependence6deriveyAA10BufferViewVADF : $@convention(thin) (@guaranteed BufferView) -> _borrow(1) @owned BufferView {
3852func derive( _ x: borrowing BufferView ) -> BufferView {
@@ -48,6 +62,9 @@ func use(_ x: borrowing BufferView) {}
4862
4963struct Wrapper : ~ Escapable {
5064 let view : BufferView
65+ init ( _ view: consuming BufferView ) {
66+ self . view = view
67+ }
5168// CHECK-LABEL: sil hidden @$s28implicit_lifetime_dependence7WrapperV8getView1AA10BufferViewVyF : $@convention(method) (@guaranteed Wrapper) -> _borrow(0) @owned BufferView {
5269 borrowing func getView1( ) -> BufferView {
5370 return view
0 commit comments