Skip to content

SIL: Resilient types don't need to be treated as addressable-for-dependencies inside their resilience domain. #81583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/swift/SIL/TypeLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class TypeLowering {
static constexpr RecursiveProperties forResilient() {
return {IsTrivial, IsFixedABI, IsNotAddressOnly, IsResilient,
IsNotTypeExpansionSensitive, HasRawPointer, IsNotLexical,
HasNoPack, IsAddressableForDependencies};
HasNoPack, IsNotAddressableForDependencies};
}

void addSubobject(RecursiveProperties other) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// RUN: %target-swift-frontend -enable-experimental-feature AddressableTypes -enable-experimental-feature LifetimeDependence -enable-library-evolution -emit-sil -verify %s

// REQUIRES: swift_feature_AddressableTypes
// REQUIRES: swift_feature_LifetimeDependence

internal struct Wrapper {
let inner: Resilient

@lifetime(borrow self)
borrowing func getSpan() -> RawSpan { self.inner.getSpan() }
}

public struct Resilient {
var field: AnyObject

@lifetime(borrow self)
borrowing func getSpan() -> RawSpan { fatalError() }
}

/*
// TODO (rdar://151268401): We still get spurious errors about escaping `self`
// in cases where the wrapped type is concretely addressable-for-dependencies.
internal struct AFDWrapper {
let inner: AFDResilient

@lifetime(borrow self)
borrowing func getSpan() -> RawSpan { self.inner.getSpan() }
}

@_addressableForDependencies
public struct AFDResilient {
@lifetime(borrow self)
borrowing func getSpan() -> RawSpan { fatalError() }
}
*/
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %target-swift-frontend %s -emit-module -emit-module-interface-path %t/test.swiftmodule \
// RUN: -swift-version 5 \
// RUN: -o /dev/null \
// RUN: -enable-library-evolution \
// RUN: -verify \
Expand Down Expand Up @@ -30,7 +31,7 @@ class C {}

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

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

Expand Down