Skip to content

Commit 560a89b

Browse files
committed
Add a test case for generic ~Escapable initialization.
This tests: - CapturePromotion handling of mark_dependence - AccessBase.storeBorrow - Unknown mark_dependence uses.
1 parent e7bc9d0 commit 560a89b

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

test/SILOptimizer/lifetime_dependence_generic.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
@_silgen_name("imagineInt64")
1515
func imagineInt64() -> Builtin.Int64
1616

17+
precedencegroup AssignmentPrecedence { assignment: true }
18+
1719
protocol P {
1820
associatedtype E: ~Escapable
1921
borrowing func getE() -> _borrow(self) E
@@ -38,6 +40,27 @@ public func pbits_ret_concerete() -> Bits {
3840
return pbits.getDefault()
3941
}
4042

43+
struct NCInt: ~Copyable {
44+
var value: Builtin.Int64
45+
46+
init(_ value: Builtin.Int64) { self.value = value }
47+
}
48+
49+
struct NEInt: ~Escapable {
50+
let value: Builtin.Int64
51+
52+
init<O: ~Copyable & ~Escapable>(v: Builtin.Int64, o: borrowing O) -> _borrow(o) Self {
53+
self.value = v
54+
return self
55+
}
56+
57+
// Test a generic storage owner.
58+
init(borrowed: borrowing NCInt) -> _borrow(borrowed) Self {
59+
self.init(v: borrowed.value, o: borrowed)
60+
return self
61+
}
62+
}
63+
4164
public func consume_indirect<NE: ~Escapable>(ne: consuming NE) -> _consume(ne) NE {
4265
return ne
4366
}

0 commit comments

Comments
 (0)