Commit Graph

240 Commits

Author SHA1 Message Date
Pavel Yaskevich
a0ab1dc40d [Frontend] Add ExtensibleAttribute to guard use of @extensible attribute
Guard against condfails when older compilers get a swift interface
that uses `@extensible` attribute. The attribute itself doesn't
have any effect in swift interfaces yet since all of the public
enums are already resilient in that mode.

(cherry picked from commit 6d89bca765)
2025-08-18 23:57:44 -07:00
Pavel Yaskevich
4579afb71d [Frontend/Serialization] Remove ExtensibleEnums experimental flag
For now the semantics provided by `@extensible` keyword on per-enum
basis. We might return this as an upcoming feature in the future with
a way to opt-out.

(cherry picked from commit bf19481ab6)
2025-08-18 23:57:08 -07:00
Doug Gregor
5abbf2e4c9 [SE-0466] Under main actor default isolation, explicit nonisolated is not special
Given an explicitly-nonisolated type such as

    nonisolated struct S { }

all extensions of S were also being treated as nonisolated. This meant
that being implicitly nonisolated (i.e., when you're using nonisolated
default isolation) was different from explicitly-writing nonisolated,
which is unfortunate and confusing. Align the rules, such that an
extension of S will get default isolation:

    extension S {
      func f() { } // @MainActor if we're in main actor default isolation
    }
2025-07-25 12:21:35 -07:00
Doug Gregor
457d44c624 [SE-0466] Enable SendableProhibitsMainActorInference by default
This implements the SE-0466 amendment under discussion for all code
with default main-actor isolation.

Finalizes rdar://151029300.
2025-07-09 10:49:03 -07:00
Doug Gregor
b5cce1f694 [SE-0466] Don't infer @MainActor on types conforming to Sendable
When the default isolation is main-actor, don't infer @MainActor
for a type that conforms to a protocol P in its primary definition when
P inherits from Sendable. Such types should remain non-isolated
because they're highly unlikely to be able to implement the P
conformance (which cannot be isolated).

Put this feature behind a new experimental flag,
SendableProhibitsMainActorInference.

Implements rdar://151029300
2025-06-27 15:14:26 -07:00
Andrew Trick
4fa7e136e9 Add Feature: NonescapableAccessorOnTrivial
To guard the new UnsafeMutablePointer.mutableSpan APIs.

This allows older compilers to ignore the new APIs. Otherwise, the type checker
will crash on the synthesized _read accessor for a non-Escapable type:

    error: cannot infer lifetime dependence on the '_read' accessor because 'self'
    is BitwiseCopyable, specify '@lifetime(borrow self)'

I don't know why the _read is synthesized in these cases, but apparently it's
always been that way.

Fixes: rdar://153773093 ([nonescapable] add a compiler feature to guard
~Escapable accessors when self is trivial)

(cherry picked from commit cc357f4f32)
2025-06-20 16:01:41 -07:00
Meghana Gupta
58b714b968 Introduce a new suppressible experimental feature to guard @_lifetime 2025-06-11 08:03:40 -07:00
Pavel Yaskevich
d3f8fd8fd7 [AST/Sema] Hide using declaration behind DefaultIsolationPerFile experimental feature
(cherry picked from commit c246a7a372)
2025-06-04 13:22:32 -07:00
Pavel Yaskevich
e12201769d [AST/Sema/SIL] Implement @_inheritActorContext(always)
- Extend `@_inheritActorContext` attribute to support optional `always` modifier.
  The new modifier will make closure context isolated even if the parameter is not
  captured by the closure.
- Implementation `@_inheritActorContext` attribute validation - it could only be
  used on parameter that have `@Sendable` or `sending` and `@isolated(any)` or
  `async` function type (downgraded to a warning until future major Swift mode
  to avoid source compatibility issues).
- Add a new language feature that guards use of `@_inheritActorContext(always)` in swift interface files
- Update `getLoweredLocalCaptures` to add an entry for isolation parameter implicitly captured by `@_inheritActorContext(always)`
- Update serialization code to store `always` modifier

(cherry picked from commit 04d46760bb)
(cherry picked from commit c050e8f75a)
(cherry picked from commit c0aca5384b)
(cherry picked from commit a4f6d710cf)
(cherry picked from commit 6c911f5d42)
(cherry picked from commit 17b8f7ef12)
2025-05-22 11:32:35 -07:00
Stephen Canon
85b304220f [6.2] Implement Builtin.select binding llvm select instruction (#81665)
Not used (yet), but needed to implement SIMD.replacing(with:where:)
idiomatically, and probably useful otherwise.

**Explanation:** Makes select available in Swift's builtin module, which
allows implementing concrete SIMD operations more efficiently.
**Risk:** Low. New builtin protected by a feature flag, currently
unused.
**Testing:** New tests added.
**Reviewers:** @eeckstein, @Azoy 
**Main branch PR:** https://github.com/swiftlang/swift/pull/81598
2025-05-21 19:14:33 -04:00
Michael Gottesman
e92e9dff0c Make Feature a struct enum so we can put methods on it.
Just noticed this as I was looking at making other changes.

(cherry picked from commit 3ff9463957)
2025-05-14 16:07:04 -07:00
Becca Royal-Gordon
e831274256 Make @abi non-experimental
This includes changing the feature name so that compilers with the experimental feature don’t accidentally pick up content that only works in the final version.

Resolves rdar://150065196.
2025-05-08 18:28:34 -07:00
Becca Royal-Gordon
ae936ac384 Prevent #if in @abi in module interfaces
When a language feature is used inside an `@abi` attribute, we should behave as though it was used on its counterpart. This was already half-implemented—we ensured the counterpart would use the feature—but we didn’t make the ABI decl aware that the counterpart was its parent for feature detection purposes. As a result, we would print `#if` inside the `@abi` attribute, which isn’t valid.
2025-05-08 18:27:58 -07:00
Michael Gottesman
322a376432 Merge pull request #81334 from gottesmm/release/6.2-rdar150695113
[6.2][swift-settings] Now that we aren't using it immediately, remove it from tree.
2025-05-06 22:41:46 -07:00
Michael Gottesman
e04e15f125 [swift-settings] Now that we aren't using it immediately, remove it from tree.
We can always get it back from the git history.

rdar://150695113
(cherry picked from commit 9d59dbed17)

Conflicts:
	include/swift/AST/DiagnosticsSema.def
	include/swift/Basic/Features.def
	test/abi/macOS/arm64/concurrency.swift
	test/abi/macOS/x86_64/concurrency.swift
2025-05-06 14:12:23 -07:00
Alejandro Alonso
12919a2300 Merge pull request #78248 from Azoy/value-generic-static-member
[NameLookup] Allow value generics to show up as static members
2025-05-05 18:42:15 -07:00
Karoy Lorentey
4cde33c4b0 Merge pull request #80867 from lorentey/is_same_metatype_condfail_6.2
[6.2][stdlib] Allow metatype comparisons to work with outdated compilers
2025-05-05 10:03:35 -07:00
Guillaume Lessard
e9b21cff7d Merge pull request #80847 from glessard/rdar149227278-nonescapable-mutating-accessor-62
[6.2, LifetimeDependenceMutableAccessors] defensive feature flag
2025-04-29 12:30:10 -07:00
Karoy Lorentey
3fce89c2e8 [stdlib] Allow metatype comparisons to work with outdated compilers
Add a new language feature to avoid the stdlib’s swiftinterface becoming unintelligible to outdated compiler builds due to the generalization of Builtin.is_same_metatype.

rdar://149396721
(cherry picked from commit 0c406b89e6)
2025-04-22 10:02:20 -07:00
Pavel Yaskevich
d007d7adfb [Frontend] Rename AsyncCallerExecution upcoming feature to NonisolatedNonsendingBeDefault
(cherry picked from commit c110941c27)
2025-04-22 00:33:45 -07:00
eeckstein
16804e6050 Merge pull request #80849 from eeckstein/copy-block-optimization-6.2
[6.2] Optimizer: remove redundant copy_block instructions
2025-04-17 14:22:56 +02:00
Pavel Yaskevich
e98ba2d0bc [Frontend] Add a feature to guard use of @concurrent and nonisolated(nonsending) in swift interface files 2025-04-16 13:20:16 -07:00
Pavel Yaskevich
3896f8fd77 [AST] Remove ExecutionAttribute experimental feature
SE-0461 has been accepted and `@concurrent` and `nonisolated(nonsending)`
can be make generally available now.
2025-04-16 13:20:12 -07:00
Pavel Yaskevich
06f880e65c [AST/ASTGen/Sema/Serialization] Remove @execution attribute
Complete the transition from `@execution` to `@concurrent` and `nonisolated(nonsending)`
2025-04-16 13:18:52 -07:00
Pavel Yaskevich
8598ec670d [AST/ASTGen] Introduce @concurrent attribute to replace @execution(concurrent) spelling 2025-04-16 10:06:08 -07:00
Erik Eckstein
9f9942855a Guard the copy_block optimization with an experimental feature flag CopyBlockOptimization 2025-04-16 14:33:27 +02:00
Guillaume Lessard
353e31edfa [LifetimeDependenceMutableAccessors] add a long feature flag 2025-04-15 22:25:18 -07:00
fahadnayyar
c37700b316 Merge pull request #80715 from swiftlang/fahadnayyar/6.2/cxx-frt-ctor
🍒 [6.2] [cxx-interop] Import public constructor of C++ foreign reference types as Swift initializers
2025-04-10 15:47:05 -07:00
fahadnayyar
f3ecb7ea8b [cxx-interop] convert CXXForeignReferenceTypeInitializers into SuppressCXXForeignReferenceTypeInitializers to be an opt-out flag
Turning the feature "ctor of C++ foreign reference types is callable as Swift Initializers" on by default.

rdar://148285972
2025-04-10 05:55:05 -07:00
Meghana Gupta
4ec6f940bd Fix printing @lifetime(&arg) for accessors in swiftinterface files 2025-04-09 10:19:12 -07:00
Meghana Gupta
00bda986a9 Introduce InoutLifetimeDependence feature 2025-04-09 10:19:11 -07:00
Allan Shortlidge
38e56fcec0 ModuleInterface: Guard declarations that use the $CustomAvailability feature. 2025-04-08 10:35:33 -07:00
fahadnayyar
9694cc8d70 [cxx-interop] Import default public ctor of C++ foreign ref types as Swift Initializer (#79986)
Building on top of PR #79288, this update synthesizes a static factory method using the default new operator, with a call to the default constructor expression for C++ foreign reference types, and imports them as Swift initializers.

rdar://147529406
2025-03-31 20:33:53 -07:00
Allan Shortlidge
e5d0cd4e51 Merge pull request #80322 from tshortli/allow-swift-runtime-symbol-declarations 2025-03-30 16:14:40 -07:00
Doug Gregor
2f5c6d21bb Collapse experimental feature StrictSendableMetatypes into IsolatedConformances 2025-03-28 16:55:33 -07:00
Allan Shortlidge
82cd87187f AST: Introduce the AllowRuntimeSymbolDeclarations experimental feature.
This feature only exists as a mechanism to suppress the warning introduced in
https://github.com/swiftlang/swift/pull/75378. The RegexParser module, which is
effectively part of the standard library, declares a Swift runtime symbol and
as a result every build of the compiler and stdlib produces warnings which
there are no plans to address. Warnings that are not going to be addressed need
some way of being suppressed, and an experimental features seems like a
reasonable mechanism for this one.
2025-03-28 12:32:47 -07:00
Anthony Latsis
631a04e56c Merge pull request #80159 from AnthonyLatsis/danaus-plexippus-5
Sema: Extend adoption mode for `AsyncCallerExecution` to storage declarations
2025-03-26 04:40:58 +00:00
Anthony Latsis
8ad2e02596 Sema: Allow @execution on storage declarations 2025-03-25 02:07:04 +00:00
Anthony Latsis
d73402af25 AST: Restrict @execution to func and init declarations 2025-03-25 02:07:04 +00:00
Kuba Mracek
f402eb623c [Compile Time Values] Add parsing of @constInitialized attribute under CompileTimeValues experimental feature 2025-03-24 09:31:57 -07:00
Pavel Yaskevich
e850f1708f [Concurrency] SE-0466: Replace UnspecifiedMeansMainActorIsolated flag with -default-isolation 2025-03-23 22:04:39 -07:00
Hamish Knight
f8ab391737 Introduce type sugar for InlineArray (#80087)
* [CS] Decline to handle InlineArray in shrink

Previously we would try the contextual type `(<int>, <element>)`,
which is wrong. Given we want to eliminate shrink, let's just bail.

* [Sema] Sink `ValueMatchVisitor` into `applyUnboundGenericArguments`

Make sure it's called for sugar code paths too. Also let's just always
run it since it should be a pretty cheap check.

* [Sema] Diagnose passing integer to non-integer type parameter

This was previously missed, though would have been diagnosed later
as a requirement failure.

* [Parse] Split up `canParseType` 

While here, address the FIXME in `canParseTypeSimpleOrComposition`
and only check to see if we can parse a type-simple, including
`each`, `some`, and `any` for better recovery.

* Introduce type sugar for InlineArray

Parse e.g `[3 x Int]` as type sugar for InlineArray. Gated behind
an experimental feature flag for now.
2025-03-23 15:31:37 -07:00
Doug Gregor
13f1bea2d3 Merge pull request #80209 from DougGregor/infer-isolated-conformances
Implement experimental feature InferIsolatedConformances
2025-03-22 17:53:20 -07:00
Doug Gregor
083194923c Implement experimental feature InferIsolatedConformances
Introduce the experimental feature InferIsolatedConformances to align
with the upcoming feature proposed in SE-0470. This is a slight
generalization of the main-actor-specific inference that was already
in place for the default-main-actor mode from SE-0466. Note that, as
specified in SE-0470, InferIsolatedConformances is implied by the
default-main-actor mode.
2025-03-21 11:41:46 -07:00
Holly Borla
be670da373 Merge pull request #79980 from hborla/closure-body-macro
[Macros] Implement support for function body macros on closures.
2025-03-21 06:19:36 -07:00
Anthony Latsis
3d3b1ca50a [NFC] AST: Turn getParameterList into a method on ValueDecl 2025-03-19 18:49:15 +00:00
Amritpan Kaur
98cd675eb9 Guard feature behind experimental flag. 2025-03-19 10:54:09 -07:00
Holly Borla
8ec70e2559 [Macros] Gate closure body macros behind an experimental feature flag. 2025-03-18 20:50:47 -07:00
Pavel Yaskevich
bb6326bb32 [AST] Adjust usesFeatureExecutionAttribute to cover accessors 2025-03-14 17:29:48 -07:00
Konrad `ktoso` Malawski
8c4dea9802 Revert "[concurrency] Add support for HopToMainActorIfNeededThunk." (#79938)
* Revert "[concurrency] Add support for HopToMainActorIfNeededThunk."

This reverts commit 0e0665bfbd.

* remove some last bits of 0e0665b
2025-03-13 06:48:03 +09:00