Commit Graph

22435 Commits

Author SHA1 Message Date
Allan Shortlidge
43fd131762 Sema: Improve MemberImportVisibility diagnostics for cross import overlays.
When `MemberImportVisibility` is enabled and a declaration from a cross import
overlay is diagnosed because it has not been imported, suggest imports of the
declaring and bystanding modules instead of the cross import overlay module
(which is an implementation detail).

Resolves rdar://149307959.
2025-04-22 10:09:24 -07:00
Doug Gregor
3ecd05593e [Diagnostics] Use the swift-syntax formatting for invalid source locations, too
The diagnostics formatter from swift-syntax previously only handled
fully-formed diagnostics anchored at a particular syntax node.
Therefore, the compiler would fall back to the existing LLVM-based
diagnostic formatter for diagnostics that had no source location.

Adopt new API in the swift-syntax diagnostics formatter that renders a
diagnostic message without requiring source location information, so
that we consistently use the swift-syntax formatter when it is
selected (which is the default).

(cherry picked from commit 235242e8b3)
2025-04-22 07:00:11 -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
Slava Pestov
fb5e67abc6 Update RuntimeVersions.def for Swift 6.1 2025-04-21 15:01:28 -04:00
Michael Gottesman
636aa31192 [sil-isolation-info] When determining isolation of a function arg, use its VarDecl.
Otherwise, we can be inconsistent with isolations returned by other parts of the
code. Previously we were just treating it always as self + nom decl, which is
clearly wrong if a type is not self (e.x.: if it is an isolated parameter).

rdar://135459885
(cherry picked from commit 0ece31e4f6)
2025-04-21 10:57:48 -07:00
Doug Gregor
ac56b63bd3 [Strict memory safety] Type alias types are only unsafe if their underlying type is
(cherry picked from commit 53ca902267)
2025-04-21 09:03:28 -07:00
Hamish Knight
32a0454d92 Merge pull request #80910 from hamishknight/macro-async-warning-6.2
[6.2] [Sema] Downgrade `noasync` diagnostic to warning for closure macro args
2025-04-19 02:18:18 +01:00
Hamish Knight
b2b37eb766 [Sema] Downgrade noasync diagnostic to warning for closure macro args
Downgrade to a warning until the next language mode. This is
necessary since we previously missed coercing macro arguments to
parameter types, resulting in cases where closure arguments weren't
being treated as `async` when they should have been.

rdar://149328745
2025-04-18 11:58:14 +01:00
Hamish Knight
15c7467f37 NFC: Abstract away the use of '7' to represent the next language mode
Introduce `Version::getFutureMajorLanguageVersion` to make it easier
to find clients that will need to be updated once we have a new
language mode.
2025-04-18 11:58:14 +01:00
Pavel Yaskevich
0af7032d91 [AST] Mark parameter declarations as caller isolated
When `nonisolated(nonsending)` parameter specifier is present
mark the declaration as caller isolated.

(cherry picked from commit 9bc96d4669)
2025-04-17 11:44:11 -07:00
Pavel Yaskevich
65f78f3c01 Merge pull request #80807 from xedin/se-0461-renamings-6.2
[6.2][SE-0461] Replace `@execution(...)` with `@concurrent` and `nonisolated(nonsending)`
2025-04-16 20:47:14 -07:00
nate-chandler
184d25e76e Merge pull request #80856 from nate-chandler/cherrypick/release/6.2/rdar148783895
6.2: [CoroutineAccessors] Only reference when available
2025-04-16 19:08:15 -07:00
Pavel Yaskevich
826176a28a [AST] NFC: Add a convenient way to create implicit NonisolatedAttrs 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
Nate Chandler
de1d5ae894 [CoroutineAccessors] Only reference when available
Don't bind references to storage to use (new ABI) coroutine accessors
unless they're guaranteed to be available.  For example, when building
against a resilient module that has coroutine accessors, they can only
be used if the deployment target is >= the version of Swift that
includes the feature.

rdar://148783895
2025-04-16 11:05:02 -07:00
Nate Chandler
85860f6960 [NFC] AST: Extract helper method.
Several callers of `AbstractStorageDecl::getAccessStrategy` only cared
about whether the the access would be via physical storage.  Before
adding more arguments to `getAccessStrategy` for which such callers
would have to pass a sentinel value, add a convenience method for this.
2025-04-16 11:05:01 -07:00
Pavel Yaskevich
fde841704c [AST/Parse] Implement nonisolated(nonsending) type modifier 2025-04-16 10:06:08 -07:00
Pavel Yaskevich
d8c64c1ff0 [AST/Sema] Intoduce nonisolated(nonsending) as a replacement for @execution(caller) 2025-04-16 10:06:08 -07:00
Pavel Yaskevich
4a973f7b4b [AST/Sema] Replace @execution(concurrent) with @concurrent 2025-04-16 10:06:08 -07:00
Pavel Yaskevich
873f562a4a [AST/Sema] Support for @concurrent attribute in type context 2025-04-16 10:06:08 -07:00
Pavel Yaskevich
8598ec670d [AST/ASTGen] Introduce @concurrent attribute to replace @execution(concurrent) spelling 2025-04-16 10:06:08 -07:00
Pavel Yaskevich
cd9741507b [Diagnostics] Adjust @execution(...) diagnostic to take DeclAttribute or StringRef
It has been decided to split the attribute into `@concurrent` and
`nonisolated(nonsending`. Adjusting diagnostics to accept the attribute
makes the transition easier.
2025-04-16 10:06:08 -07:00
Doug Gregor
cf3bf78bb2 Merge pull request #80824 from DougGregor/diag-group-docs-on-swift-org-6.2
[6.2] Point at diagnostic group documentation on docs.swift.org
2025-04-16 05:29:33 -07:00
Rashmi Mudduluru
942eddf01e [SUA][IRGen] Add stub for swift_coroFrameAlloc that weakly links against the runtime function (#79889) (#80769)
* [SUA][IRGen] Add stub for swift_coroFrameAlloc that weakly links against the runtime function

This commit modifies IRGen to emit a stub function `__swift_coroFrameAllocStub` instead of the
newly introduced swift-rt function `swift_coroFrameAlloc`. The stub checks whether the runtime has the symbol
`swift_coroFrameAlloc` and dispatches to it if it exists, uses `malloc` otherwise. This ensures the
ability to back deploy the feature to older OS targets.

rdar://145239850
(cherry picked from commit 5e2f20b2d8)
2025-04-15 16:45:41 -07:00
Steven Wu
bd23859a4a Merge pull request #80751 from cachemeifyoucan/eng/PR-148465899-6.2
[6.2][Caching][Macro] Make macro plugin options cacheable
2025-04-15 09:05:33 -07:00
Doug Gregor
50f0ebca9f Drop the ".md" suffix from diagnostic group file names in GROUP
While here, document the GROUP macro appropriately.
2025-04-15 07:03:22 -07:00
Doug Gregor
89f246985e Collapse two implementations into ExistentialLayout::containsNonMarkerProtocols
(cherry picked from commit 53707a121c)
2025-04-14 16:38:41 -07:00
Doug Gregor
5e29333d6b [SE-0470] Enable isolated conformances by default
The IsolatedConformances feature moves to a normal, supported feature.
Remove all of the experimental-feature flags on test cases and such.

The InferIsolatedConformances feature moves to an upcoming feature for
Swift 7. This should become an adoptable feature, adding "nonisolated"
where needed.

(cherry picked from commit 3380331e7e)
2025-04-14 16:38:22 -07:00
Doug Gregor
69758f6213 [SE-0470] Downgrade some isolated conformance-related errors to warnings in Swift 5
(cherry picked from commit e8b3065293)
2025-04-14 16:36:57 -07:00
Doug Gregor
49ebfcbab2 Move generic signature check for isolated conformances into GenericSignatureImpl
This is going to need a proper implementation in the requirement
machine. For the moment, provide a slightly-less-broken implementation
but leave a test case where we incorrectly accept racey code.

(cherry picked from commit 92774e0a3c)
2025-04-14 16:36:54 -07:00
Gábor Horváth
710c26e87d Merge pull request #80710 from swiftlang/gaborh/escapable-type-nonesc-field-on-6.2 2025-04-14 11:10:04 -07:00
Alastair Houghton
670be7df63 [Concurrency] Remove -executor-factory option and replace with magic type.
We decided that using a magic typealias to set the executor factory was better
than using a compiler option. Remove the `-executor-factory` option, and replace
by looking up the `DefaultExecutorFactory` type, first in the main module, and
then if that fails in Concurrency.

rdar://149058236
2025-04-14 09:23:03 +01:00
Andrew Trick
097dba34ff Merge pull request #80709 from atrick/62-irgen-addressable
[6.2] Fix IRGen for @_addressable params which may be "captured".
2025-04-11 18:03:01 -07:00
Steven Wu
f96b81975a [Caching][Macro] Make macro plugin options cacheable
Currently, the macro plugin options are included as cache key and the
absolute path of the plugin executable and library will affect cache
hit, even the plugin itself is identical.

Using the new option `-resolved-plugin-validation` flag, the macro
plugin paths are remapped just like the other paths during dependency
scanning. `swift-frontend` will unmap to its original path during the
compilation, make sure the content hasn't changed, and load the plugin.
It also hands few other corner cases for macro plugins:

* Make sure the plugin options in the swift module is prefix mapped.
* Make sure the remarks of the macro loading is not cached, as the
  mesasge includes the absolute path of the plugin, and is not
  cacheable.

rdar://148465899
(cherry picked from commit 3d38d0dd56)
2025-04-10 16:52:15 -07:00
Nate Chandler
77055a5eb1 [CoroutineAccessors] Control ABI via flag. 2025-04-10 14:47:05 -07:00
Andrew Trick
e048dd1cf1 Fix IRGen for @_addressable params which may be "captured".
Simply omit the 'nocapture' attribute on the parameter.

Fixes rdar://148039510 ([nonescapable] IRGen: lower addressable
params to LLVM: captures(ret: address, provenance))

(cherry picked from commit 2d9df8ff78)
2025-04-10 09:43:13 -07:00
Meghana Gupta
b3881cde1d Merge pull request #80645 from meg-gupta/lifetimeinoutcp
[6.2] Add support for inout lifetime dependencies
2025-04-10 03:04:28 -07:00
Gábor Horváth
8c4be8a37d [6.2][cxx-interop] Diagnose Escapable C++ types with non-escapable fields
Explanation: In Swift, Escapable types cannot have non-escapable stored
properties. Unfortunately, these checks could be circumvented via C++
interop, constructing invalid Swift code. This patch errors out on
importing C++ code of this shape.
Issue: rdar://148899224
Risk: Low, the fix is fairly targeted to the affected scenario.
Testing: Added tests to test suite
Original PR: #80671
Reviewer: John Hui
2025-04-10 10:23:57 +01:00
Andrew Trick
8802395ab3 Merge pull request #80652 from atrick/62-address-specialize
[6.2] Fix GenericSpecializer for addressable parameters.
2025-04-09 13:53:07 -07:00
Meghana Gupta
374ceb6a80 [NFC] Update diagnostic msg 2025-04-09 10:18:11 -07:00
Meghana Gupta
96aeea9f2b Rename ParsedLifetimeDependenceKind::Scope -> ParsedLifetimeDependenceKind::Borrow 2025-04-09 10:18:11 -07:00
Meghana Gupta
91ad1451ce Add support for @lifetime(&arg) 2025-04-09 10:18:11 -07:00
Andrew Trick
78c9fe4c56 Add SILFunctionType::isAddressable & ApplySite::isAddressable.
(cherry picked from commit 501abb0975)
2025-04-08 14:02:19 -07:00
Allan Shortlidge
1cd636d9b3 Serialization: Encode custom availability domains.
When serializing `@available` attributes, if the attribute applies to a custom
domain include enough information to deserialize the reference to that domain.

Resolves rdar://138441265.
2025-04-08 10:35:32 -07:00
Hamish Knight
e8c85fa34b Merge pull request #80599 from hamishknight/cap-req-6.2
[6.2] [Sema] Requestify PatternBindingDecl capture computation
2025-04-08 03:30:47 +01:00
Hamish Knight
362a239b02 Merge pull request #80581 from hamishknight/mangle-less-6.2
[6.2] [Mangler] Avoid mangling local discriminator for attached macros
2025-04-07 18:58:30 +01:00
Hamish Knight
999169e7ae [Sema] Requestify PatternBindingDecl capture computation
Introduce `PatternBindingCaptureInfoRequest`, and kick it after
contextualizing a property initializer. This ensures it gets run
for stored properties added by macro expansions.

rdar://143429551
2025-04-07 17:29:36 +01:00
Hamish Knight
e1a864d867 [Mangler] Avoid mangling local discriminator for attached macros
If we're using the macro-specific local discriminator, we need to
make sure we avoid mangling the regular local discriminator in
`appendDeclName`, since that could prematurely kick local discriminator
assignment before type-checking has finished.

rdar://143834482
2025-04-07 10:26:56 +01:00
Joe Groff
81576a639f Canonicalize different spellings of the same integer generic parameter.
`Foo<256>`, `Foo<2_56>`, and `Foo<0x100>` are all canonically the same type.
Fixes rdar://144736386.
2025-04-04 10:40:15 -07:00