Skip to content
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

[stdlib] Optional: Allow non-escapable wrapped types #73258

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions stdlib/public/core/Optional.swift
Expand Up @@ -118,7 +118,7 @@
/// Unconditionally unwrapping a `nil` instance with `!` triggers a runtime
/// error.
@frozen
public enum Optional<Wrapped: ~Copyable>: ~Copyable {
public enum Optional<Wrapped: ~Copyable & ~Escapable>: ~Copyable, ~Escapable {
// The compiler has special knowledge of Optional<Wrapped>, including the fact
// that it is an `enum` with cases named `none` and `some`.

Expand All @@ -132,9 +132,11 @@ public enum Optional<Wrapped: ~Copyable>: ~Copyable {
case some(Wrapped)
}

extension Optional: Copyable /* where Wrapped: Copyable */ {}
extension Optional: Copyable where Wrapped: ~Escapable {}

extension Optional: Sendable where Wrapped: ~Copyable & Sendable { }
extension Optional: Escapable where Wrapped: ~Copyable {}

extension Optional: Sendable where Wrapped: ~Copyable & ~Escapable & Sendable {}

extension Optional: _BitwiseCopyable where Wrapped: _BitwiseCopyable { }

Expand Down
2 changes: 1 addition & 1 deletion utils/build_swift/build_swift/driver_arguments.py
Expand Up @@ -1404,7 +1404,7 @@ def create_argument_parser():
help='Enable experimental Swift distributed actors.')

option('--enable-experimental-nonescapable-types', toggle_true,
default=False,
default=True,
help='Enable experimental NonescapableTypes.')

option('--enable-experimental-string-processing', toggle_true,
Expand Down