Skip to content

Commit 10a80f5

Browse files
authored
Merge pull request #81583 from jckarter/resilient-types-arent-addressable-inside-resilience-domain
SIL: Resilient types don't need to be treated as addressable-for-dependencies inside their resilience domain.
2 parents 0c197d1 + 21c1790 commit 10a80f5

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

include/swift/SIL/TypeLowering.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ class TypeLowering {
266266
static constexpr RecursiveProperties forResilient() {
267267
return {IsTrivial, IsFixedABI, IsNotAddressOnly, IsResilient,
268268
IsNotTypeExpansionSensitive, HasRawPointer, IsNotLexical,
269-
HasNoPack, IsAddressableForDependencies};
269+
HasNoPack, IsNotAddressableForDependencies};
270270
}
271271

272272
void addSubobject(RecursiveProperties other) {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// RUN: %target-swift-frontend -enable-experimental-feature AddressableTypes -enable-experimental-feature LifetimeDependence -enable-library-evolution -emit-sil -verify %s
2+
3+
// REQUIRES: swift_feature_AddressableTypes
4+
// REQUIRES: swift_feature_LifetimeDependence
5+
6+
internal struct Wrapper {
7+
let inner: Resilient
8+
9+
@lifetime(borrow self)
10+
borrowing func getSpan() -> RawSpan { self.inner.getSpan() }
11+
}
12+
13+
public struct Resilient {
14+
var field: AnyObject
15+
16+
@lifetime(borrow self)
17+
borrowing func getSpan() -> RawSpan { fatalError() }
18+
}
19+
20+
/*
21+
// TODO (rdar://151268401): We still get spurious errors about escaping `self`
22+
// in cases where the wrapped type is concretely addressable-for-dependencies.
23+
internal struct AFDWrapper {
24+
let inner: AFDResilient
25+
26+
@lifetime(borrow self)
27+
borrowing func getSpan() -> RawSpan { self.inner.getSpan() }
28+
}
29+
30+
@_addressableForDependencies
31+
public struct AFDResilient {
32+
@lifetime(borrow self)
33+
borrowing func getSpan() -> RawSpan { fatalError() }
34+
}
35+
*/

test/SILOptimizer/lifetime_dependence/verify_library_diagnostics.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %target-swift-frontend %s -emit-module -emit-module-interface-path %t/test.swiftmodule \
2+
// RUN: -swift-version 5 \
23
// RUN: -o /dev/null \
34
// RUN: -enable-library-evolution \
45
// RUN: -verify \
@@ -30,7 +31,7 @@ class C {}
3031

3132
// Test diagnostics on keypath getter.
3233
//
33-
// FIXME: rdar://150073405 ([SILGen] support synthesized _modify on top of borrowed getters with library evolution)
34+
// rdar://150073405 ([SILGen] support synthesized _modify on top of borrowed getters with library evolution)
3435
//
3536
// This produces the error:
3637
// <unknown>:0: error: unexpected error produced: lifetime-dependent value returned by generated thunk
@@ -55,8 +56,6 @@ public struct NoncopyableImplicitAccessors : ~Copyable & ~Escapable {
5556
public var ne: NE
5657

5758
public var neComputedBorrow: NE {
58-
// expected-error @-1{{lifetime-dependent value returned by generated accessor '_modify'}}
59-
// expected-note @-2{{it depends on this scoped access to variable 'self'}}
6059
@lifetime(borrow self)
6160
get { ne }
6261

0 commit comments

Comments
 (0)