Skip to content

Commit 2a9a780

Browse files
authored
Merge pull request #73096 from meg-gupta/unsafeattr
Allow `@_unsafeNonescapableResult` on accessors
2 parents cae177f + 2db6fe2 commit 2a9a780

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

include/swift/AST/DeclAttr.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ SIMPLE_DECL_ATTR(_nonescapable, NonEscapable,
372372
OnNominalType | UserInaccessible | ABIBreakingToAdd | ABIStableToRemove | APIBreakingToAdd | APIStableToRemove,
373373
148)
374374
SIMPLE_DECL_ATTR(_unsafeNonescapableResult, UnsafeNonEscapableResult,
375-
OnAbstractFunction | OnSubscript | UserInaccessible | ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIBreakingToRemove,
375+
OnAbstractFunction | OnSubscript | OnAccessor | UserInaccessible | ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIBreakingToRemove,
376376
149)
377377
CONTEXTUAL_SIMPLE_DECL_ATTR(final, Final,
378378
OnClass | OnFunc | OnAccessor | OnVar | OnSubscript | DeclModifier | ABIBreakingToAdd | ABIBreakingToRemove | APIStableToAdd | APIStableToRemove,

test/attr/attr_nonEscapable.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// RUN: %target-typecheck-verify-swift -enable-experimental-feature NonescapableTypes
1+
// RUN: %target-typecheck-verify-swift -enable-experimental-feature NonescapableTypes -enable-experimental-feature NoncopyableGenerics
22

33
// REQUIRES: asserts
44

5-
@_nonescapable public struct NES {
5+
public struct NES : ~Escapable {
66
let x: Int
77

88
@_unsafeNonescapableResult
@@ -15,3 +15,12 @@
1515
return NES()
1616
}
1717
}
18+
19+
struct BC {
20+
public var nes: NES {
21+
@_unsafeNonescapableResult
22+
get {
23+
NES()
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)