Commit Graph

3997 Commits

Author SHA1 Message Date
Allan Shortlidge
10c910ed83 ModuleInterface: Guard declarations that use the $CustomAvailability feature. 2025-04-08 08:53:44 -07:00
Michael Gottesman
77a86a525b Merge pull request #79891 from gottesmm/pr-9df6772bb44656cbd85cad72ee5c3637caab8956
Make Feature a struct enum so we can put methods on it.
2025-04-07 10:32:23 -07:00
Meghana Gupta
2d9217bb4f Merge pull request #80541 from meg-gupta/inoutreland
Reland #80452
2025-04-07 10:20:10 -07:00
Hamish Knight
8834f6c4c7 Merge pull request #80496 from hamishknight/message-in-a-crash-log
[Mangler] Include verification errors in the crash log
2025-04-07 17:03:18 +01:00
Michael Gottesman
3ff9463957 Make Feature a struct enum so we can put methods on it.
Just noticed this as I was looking at making other changes.
2025-04-05 10:08:29 +01:00
Meghana Gupta
ef1e94577f Revert "Merge pull request #80540 from swiftlang/revert-80452-lifetimeinout"
This reverts commit 6eaa07a880, reversing
changes made to e75ee3f4cf.
2025-04-04 09:50:13 -07:00
Artem Chikin
6eaa07a880 Merge pull request #80540 from swiftlang/revert-80452-lifetimeinout
Revert "Add support for inout lifetime dependence"
2025-04-04 09:31:46 -07:00
Pavel Yaskevich
8bf8c24bf9 Merge pull request #80503 from xedin/extensible-attr
[AST/Sema] Add `@extensible` attribute on `enum` declarations
2025-04-04 09:17:56 -07:00
Artem Chikin
39e1791b67 Revert "Add support for inout lifetime dependence" 2025-04-04 09:00:09 -07:00
Meghana Gupta
50ea777936 Merge pull request #80452 from meg-gupta/lifetimeinout
Add support for inout lifetime dependence
2025-04-04 02:04:53 -07:00
Meghana Gupta
493f0b782e Introduce InoutLifetimeDependence feature 2025-04-03 17:32:09 -07:00
Pavel Yaskevich
bf19481ab6 [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.
2025-04-03 16:30:23 -07:00
3405691582
782ef64931 Fix the bootstrap build.
Otherwise, referring to swift_ASTGen_bridgedSwiftClosureCall_1 results in
a linker error on a bootstrap build (i.e., without Swift host tools
available).
2025-04-03 16:40:47 -04:00
Doug Gregor
e49afc8797 Merge pull request #80389 from 3405691582/nobtcfi
Add a build flavor to opt-out of BTCFI on OpenBSD.
2025-04-03 13:29:04 -07:00
Hamish Knight
54023f85e7 [Basic] Introduce abortWithPrettyStackTraceMessage
Introduce a convenience for aborting while printing a given message
to a frame of the pretty stack trace. Use this in the existing places
where we're currently doing this.
2025-04-03 15:59:48 +01: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
Alastair Houghton
b1c345f1be Merge pull request #80266 from al45tair/custom-executors-take2
[Concurrency] Provide a Swift interface for custom main and global executors.
2025-03-31 09:53:48 +01:00
Allan Shortlidge
e5d0cd4e51 Merge pull request #80322 from tshortli/allow-swift-runtime-symbol-declarations 2025-03-30 16:14:40 -07:00
3405691582
a341ce5570 Add a build flavor to opt-out of BTCFI on OpenBSD.
To work-around #80059, we need to stop return address signing and
opt-out of BTCFI enforcement via enabling a platform linker option.

We don't want to completely undo the BTCFI work in the rare case that
we later figure out how to properly address the above issue, or allow
users who might want to benefit from BTCFI enforcement and won't use
Concurrency. To do this, condition the existing BTCFI flag enforcement
into a configuration option that defaults to off for now.

Because the new swift-driver needs to "know" whether the frontend is
configured to opt-out or not, and since the new driver communicates with
the frontend via the target info JSON to begin with, we add a field
that emits the build flavor to signal the right behavior.
2025-03-29 10:47:23 -04:00
Doug Gregor
813f1dcb85 Merge pull request #80384 from DougGregor/isolated-conformances-checkedcast-enable
Prohibit isolated conformances for checked casts to potentially-SendableMetatype types
2025-03-29 01:27:31 -07:00
Doug Gregor
2f5c6d21bb Collapse experimental feature StrictSendableMetatypes into IsolatedConformances 2025-03-28 16:55:33 -07:00
Doug Gregor
7d569b989d [Diagnostics] Remove rendering of educational notes to the terminal
We're moving over to a model where we provide direct links to educational notes /
diagnostic group notes whenever relevant. Rendering the Markdown from these
files to the terminal is less relevant with this approach, so remove it from the
compiler.
2025-03-28 14:12:27 -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
Alastair Houghton
47fa71787f Revert "Merge pull request #80224 from glessard/revert-79789-custom-executors"
This reverts commit 06f6358067, reversing
changes made to 033f6679e8.
2025-03-28 10:15:07 +00:00
Becca Royal-Gordon
132f49108d Check attributes in @abi attr
This commit compares the attributes on the decl inside the `@abi` attribute to those in the decl it’s attached to, diagnosing ABI-incompatible differences. It also rejects many attributes that don’t need to be specified in the `@abi` attribute, such as ObjC-ness, access control, or ABI-neutral traits like `@discardableResult`, so developers know to remove them.
2025-03-26 10:47:57 -07:00
Pavel Yaskevich
e850f1708f [Concurrency] SE-0466: Replace UnspecifiedMeansMainActorIsolated flag with -default-isolation 2025-03-23 22:04:39 -07:00
Pavel Yaskevich
2221c140d2 [Frontend] SE-0466: Add -default-isolation frontend that accepts MainActor and nonisolated 2025-03-23 22:04:32 -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
Alastair Houghton
8b15b05c63 Revert "[Concurrency] Provide a Swift interface for custom main and global executors." 2025-03-22 02:38:11 -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
Alastair Houghton
8443b5f76c Merge pull request #79789 from al45tair/custom-executors
[Concurrency] Provide a Swift interface for custom main and global executors.
2025-03-21 09:05:03 +00:00
Amritpan Kaur
3c30d68d2e Merge pull request #78823 from amritpan/method-keypaths
[Sema/SILGen/IRGen] Implement method & initializer keypaths.
2025-03-19 18:59:17 -07:00
Andrew Trick
5d2c829b6a LifetimeDependence: implement strict type checking
Rework the type checker to support completely checking lifetime dependence
requirements. Don't let anything through without the feature being enabled and
complete annotation or inference.

First, prevent lifetime dependencies from sneaking into source that does not
enable LifetimeDependence. This is essential for controlling the scope of the
feature.

Fixing this is disruptive because, ever since `~Escapable` was introduced we
have been declaring empty non-Escapable types without enabling
LifetimeDependence. Such as:

      struct Implicit_Init_Nonescapable : ~Escapable {}

Fixes: rdar://145979187 ([nonescapable] diagnose implicit non-Escapable
initializers as an error unless LifetimeDependence is enabled)

Various forms of unsupported 'inout' dependencies are now also caught by the
type checker.

Second, disable lifetime dependency inferrence except in unambiguous cases and
some implicitly generated cases.

Fixes: rdar://131176898 ([nonescapable] missing diagnostic for incorrectly inferred inherited dependence)

This is important to avoid source compatibility problems as inference rules
change. They will change as the proposal goes through review.

This fixes various latent missing dependency bugs.

Disable experimental lifetime dependence inference. Unambiguous lifetime
dependency candidates will still be inferred by default, without any frontend
options. Ambiguous candidates will, however, no longer be inferred unless
-Xfrontend -enable_experimental_lifetime_dependence_inference is enabled.

This all has to be done without breaking existing .swiftinterface files. So
backward compatibility logic is maintained.

Examples of inference rules that are no longer enabled by default:

1. do not infer a dependency on non-Escapable 'self' for methods with more than
zero parameters:

    extension NE: ~Escapable {
      /*@lifetime(self)*/ // ERROR: 'self' not inferred
      func method<Arg>(arg: Arg) -> NE { ... }
    }

2. Never infer a 'copy' dependency kind for explicit functions

    extension NE: ~Escapable {
      @lifetime(self) // ERROR: 'copy' not inferred
      func method() -> NE { ... }

      @lifetime(self) // ERROR: 'copy' not inferred
      var property : NE { /*@lifetime(self: newValue)*/ set { ... } }
    }
2025-03-19 11:59:04 -07: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
Anthony Latsis
ad3a5adc6d Merge pull request #80008 from AnthonyLatsis/danaus-plexippus-4 2025-03-18 13:24:17 +00:00
Anthony Latsis
c49947579a Sema: Implement adoption mode for AsyncCallerExecution 2025-03-18 01:58:31 +00:00
Michael Gottesman
13c9e9c994 [gardening] Remove this-> from LangOpts that was added by mistake. 2025-03-17 15:37:15 -07:00
Pavel Yaskevich
26eaf7566d Merge pull request #80004 from xedin/se-0463-enablement
[Frontend] SE-0463: Enable `SendableCompletionHandlers` feature by default
2025-03-14 11:24:44 -07:00
John Hui
76a1742aca [cxx-interop] Use formal C++ interop mode to fix name lookup in module interfaces (#79984)
It is possible for a module interface (e.g., ModuleA) to be generated
with C++ interop disabled, and then rebuilt with C++ interop enabled
(e.g., because ModuleB, which imports ModuleA, has C++ interop enabled).

This circumstance can lead to various issues when name lookup behaves
differently depending on whether C++ interop is enabled, e.g., when
a module name is shadowed by a namespace of the same name---this only
happens in C++ because namespaces do not exist in C. Unfortunately,
naming namespaces the same as a module is a common C++ convention,
leading to many textual interfaces whose fully-qualified identifiers
(e.g., c_module.c_member) cannot be correctly resolved when C++ interop
is enabled (because c_module is shadowed by a namespace of the same
name).

This patch does two things. First, it introduces a new frontend flag,
-formal-cxx-interoperability-mode, which records the C++ interop mode
a module interface was originally compiled with. Doing so allows
subsequent consumers of that interface to interpret it according to the
formal C++ interop mode. Note that the actual "versioning" used by this
flag is very crude: "off" means disabled, and "swift-6" means enabled.
This is done to be compatible with C++ interop compat versioning scheme,
which seems to produce some invalid (but unused) version numbers. The
versioning scheme for both the formal and actual C++ interop modes
should be clarified and fixed in a subsequent patch.

The second thing this patch does is fix the module/namespace collision
issue in module interface files. It uses the formal C++ interop mode to
determine whether it should resolve C++-only decls during name lookup.
For now, the fix is very minimal and conservative: it only filters out
C++ namespaces during unqualified name lookup in an interface that was
originally generated without C++ interop. Doing so should fix the issue
while minimizing the chance for collateral breakge. More cases other
than C++ namespaces should be added in subsequent patches, with
sufficient testing and careful consideration.

rdar://144566922
2025-03-13 23:24:18 -07:00
Pavel Yaskevich
4ce370d0b8 [Frontend] SE-0463: Enable SendableCompletionHandlers feature by default 2025-03-13 15:34:34 -07:00
Artem Chikin
27bac69527 Merge pull request #79930 from artemcm/ClangTargetVariant
[Explicit Module Builds] Add '-clang-target-variant' flag
2025-03-13 07:21:09 -07:00
Alastair Houghton
55afa47bea [Concurrency] More work on the custom executor implementation.
Added an `-executor-factory` argument to the compiler to let you safely
specify the executors you wish to use (by naming a type that returns
them).

Also added some tests of the new functionality.

rdar://141348916
2025-03-13 13:34:41 +00: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
Tony Allevato
68876a6d4a Merge pull request #76636 from allevato/rich-identifiers
Support raw identifiers (backtick-delimited identifiers containing non-identifier characters).
2025-03-12 14:56:14 -04:00
Artem Chikin
e96a690cc7 [Explicit Module Builds] Add '-clang-target-variant' flag
https://github.com/swiftlang/swift/pull/37774 added '-clang-target' which allows us to specify a target triple that only differs from '-target' by the OS version, when we want to provide a different OS version for API availability and type-checking, in order to set a common/unified target triple for the entire Clang module dependency graph, for presenting a unified API surface to the Swift client, serving as a maximum type-checking epoch.

This change adds an equivalent flag for the '-target-variant' configuration, as a mechanism to ensure that the entire module dependency graph presents a consistent os version.
2025-03-11 15:48:06 -07:00
Tony Allevato
7797664bb4 Add RawIdentifiers as a language feature.
This lets clients test `#if hasFeature(RawIdentifiers)` to
determine compiler support.
2025-03-11 17:26:27 -04:00
Tony Allevato
d94bd80c62 Add support for raw identifiers.
Raw identifiers are backtick-delimited identifiers that can contain any
non-identifier character other than the backtick itself, CR, LF, or other
non-printable ASCII code units, and which are also not composed entirely
of operator characters.
2025-03-11 17:18:43 -04:00