Skip to content

Allow @_unsafeNonescapableResult on accessors #73096

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
merged 1 commit into from
Apr 18, 2024
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/AST/DeclAttr.def
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ SIMPLE_DECL_ATTR(_nonescapable, NonEscapable,
OnNominalType | UserInaccessible | ABIBreakingToAdd | ABIStableToRemove | APIBreakingToAdd | APIStableToRemove,
148)
SIMPLE_DECL_ATTR(_unsafeNonescapableResult, UnsafeNonEscapableResult,
OnAbstractFunction | OnSubscript | UserInaccessible | ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIBreakingToRemove,
OnAbstractFunction | OnSubscript | OnAccessor | UserInaccessible | ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIBreakingToRemove,
149)
CONTEXTUAL_SIMPLE_DECL_ATTR(final, Final,
OnClass | OnFunc | OnAccessor | OnVar | OnSubscript | DeclModifier | ABIBreakingToAdd | ABIBreakingToRemove | APIStableToAdd | APIStableToRemove,
Expand Down
13 changes: 11 additions & 2 deletions test/attr/attr_nonEscapable.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// RUN: %target-typecheck-verify-swift -enable-experimental-feature NonescapableTypes
// RUN: %target-typecheck-verify-swift -enable-experimental-feature NonescapableTypes -enable-experimental-feature NoncopyableGenerics

// REQUIRES: asserts

@_nonescapable public struct NES {
public struct NES : ~Escapable {
let x: Int

@_unsafeNonescapableResult
Expand All @@ -15,3 +15,12 @@
return NES()
}
}

struct BC {
public var nes: NES {
@_unsafeNonescapableResult
get {
NES()
}
}
}