Skip to content

Conversation

@kavon
Copy link
Member

@kavon kavon commented Jan 7, 2026

This experimental feature allows you to override the default behavior of a 'get' returning a noncopyable type, so that it returns an owned value rather than a borrow, when that getter is exposed in opaque interfaces like protocol requirements or resilient types.

resolves rdar://157318147

This experimental feature allows you to override the default behavior
of a 'get' returning a noncopyable type, so that it returns an owned
value rather than a borrow, when that getter is exposed in opaque
interfaces like protocol requirements or resilient types.

resolves rdar://157318147
@kavon
Copy link
Member Author

kavon commented Jan 7, 2026

@swift-ci smoke test

@kavon kavon enabled auto-merge January 7, 2026 00:41
@nkcsgexi
Copy link
Contributor

nkcsgexi commented Jan 7, 2026

Will the @_owned attributes be printed into textual interfaces?

@kavon
Copy link
Member Author

kavon commented Jan 7, 2026

Yes, it is printed in the textual interface (see the SILGen/owned_attr.swift test). Properties with @_owned are #if-guarded by $UnderscoreOwned feature availability in the interface file. No -enable-experimental-feature UnderscoreOwned is required to use @_owned; compilers either know about it, or shouldn't see the property declaration in the interface.

@nkcsgexi
Copy link
Contributor

nkcsgexi commented Jan 7, 2026

Thank you for the context, Kavon! I think we should drop the UserInaccessible bit to leverage the existing infrastructure that guards attribute printing. Doug made a similar change recently for @_c in #86293.

@kavon
Copy link
Member Author

kavon commented Jan 7, 2026

@swift-ci smoke test

@kavon kavon enabled auto-merge January 7, 2026 18:05
@kavon
Copy link
Member Author

kavon commented Jan 7, 2026

@swift-ci smoke test macOS

@kavon kavon merged commit adf1492 into swiftlang:main Jan 8, 2026
3 checks passed
@kavon kavon deleted the noncopyable-opaque-read-ownership branch January 8, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants