Skip to content

Commit b4b1dfe

Browse files
committed
[CoroutineAccessors] Infer same lifetime deps.
When the feature is enabled, a read2 accessor is generated when a mutating getter is declared. rdar://149385088
1 parent d7b44f4 commit b4b1dfe

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

lib/AST/LifetimeDependence.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,8 @@ class LifetimeDependenceChecker {
11001100
}
11011101
switch (accessor->getAccessorKind()) {
11021102
case AccessorKind::Read:
1103-
// An implicit _read accessor is generated when a mutating getter is
1103+
case AccessorKind::Read2:
1104+
// An implicit _read/read accessor is generated when a mutating getter is
11041105
// declared. Emit the same lifetime dependencies as an implicit _modify.
11051106
case AccessorKind::Modify:
11061107
case AccessorKind::Modify2:
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: %target-typecheck-verify-swift \
2+
// RUN: -enable-experimental-feature LifetimeDependence \
3+
// RUN: -enable-experimental-feature CoroutineAccessors
4+
5+
// REQUIRES: swift_feature_LifetimeDependence
6+
// REQUIRES: swift_feature_CoroutineAccessors
7+
8+
struct NE<T : ~Copyable & ~Escapable> : ~Copyable & ~Escapable {
9+
@lifetime(&t)
10+
init(
11+
t: inout T
12+
)
13+
{
14+
}
15+
}
16+
17+
struct S : ~Copyable & ~Escapable {
18+
var mutableBytes: NE<S> {
19+
@lifetime(&self)
20+
mutating get {
21+
return NE(t: &self)
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)