Commit Graph

103370 Commits

Author SHA1 Message Date
Artem Chikin
01e5d4433f [Dependency Scanning][C++ Interop] Do not skip lookup of 'CxxStdlib' overlay for the source module
A prior change ensured that we forego this query when looking up Swift overlays for a textual interface which was built without C++ interop. This change introduced a bug where it also caused us to skip this lookup for the main source module. This commit resolves that by preserving the fix above but also ensuring we perform the lookup for the main source module under scan.
2025-07-03 09:20:29 -07:00
Pavel Yaskevich
01404bf1ae Merge pull request #82735 from xedin/rdar-154754939-6.2
[6.2][Concurency] Allow declarations with `@isolated(any)` parameters be m…
2025-07-03 09:17:34 -07:00
Pavel Yaskevich
cf5ab749eb Merge pull request #82744 from xedin/rdar-154808850-6.2
[6.2][Concurrency] SE-0461: Extend `nonisolated(nonsending)` inference to …
2025-07-03 09:17:21 -07:00
Charles Zablit
da7764efd2 [NFC][demangling] switch to using NodePrinter::printFunctionName 2025-07-03 15:33:34 +01:00
Hamish Knight
ef8e576d23 Merge pull request #82741 from hamishknight/err-val-6.2
[6.2] [AST] Use ErrorType for invalid value generic parameter
2025-07-03 14:32:44 +01:00
Erik Eckstein
849a5e9082 MandatoryPerformanceOptimizations: don't de-virtualize a generic class method call to specialized method
This results in wrong argument/return calling conventions.
First, the method call must be specialized. Only then the call can be de-virtualized.
Usually, it's done in this order anyway, because the `class_method` instruction is located before the `apply`.
But when inlining functions, the order (in the worklist) can be the other way round.

Fixes a compiler crash.
rdar://154631438
2025-07-03 13:21:27 +02:00
Erik Eckstein
a538252a77 MoveOnlyWrappedTypeEliminator: handle EndCOWMutationAddr
fixes a compiler crash
rdar://154416511
2025-07-03 13:10:00 +02:00
Gábor Horváth
93e1c787f0 [6.2][cxx-interop] Fix a crash when exposing @objc Swift classes
Explanation: There was a null pointer dereference in reverse interop
when we wanted to expose an ObjC class written in Swift. There was a
crash during generating the scaffolding we do for Clang types. Since
the type is written in Swift, no such scaffolding is needed, this patch
skips this operation avoiding the null dereference.
Scope: Reverse C++ interop when exposing @ObjC classes written in Swift.
Issues: rdar://154252454
Original PRs: #82684
Risk: Low, the fix is narrow to the affected scenario.
Testing: Added a compiler test.
Reviewers: @egorzhdan
2025-07-03 09:25:38 +01:00
Hamish Knight
2e0b9d7f8a Merge pull request #82743 from hamishknight/diag-it-6.2 2025-07-03 09:24:25 +01:00
Slava Pestov
8e78de3a70 Sema: Fix leading dot with protocol composition or parameterized protocol contextual type
- Fixes https://github.com/swiftlang/swift/issues/60552.
- Fixes rdar://problem/99699879.
2025-07-03 00:22:31 -04:00
Slava Pestov
6fbf38f63d Merge pull request #82693 from slavapestov/fix-issue-82614-6.2
[6.2] Concurrency: Move PackExpansionType check to swift::diagnoseNonSendableTypes()
2025-07-02 22:57:00 -04:00
nate-chandler
e3f8048628 Merge pull request #82700 from nate-chandler/cherrypick/release/6.2/rdar154652254
6.2: [CSE] Fix combine of type_value.
2025-07-02 16:51:56 -07:00
Egor Zhdan
40c4f3cd9d Merge pull request #82723 from swiftlang/egorzhdan/6.2-cfoptions-block-param
🍒[cxx-interop] Fix generated header for Swift closures using `CF_OPTIONS` types
2025-07-02 23:54:40 +01:00
Pavel Yaskevich
d1a1b2fb31 [Concurrency] SE-0461: Extend nonisolated(nonsending) inference to function types
Currently only declarations would get `nonisolated(nonsending)`
inferred if the upcoming flag is enabled, this changes extend
this to apply to asynchronous nonisolated function types as well.

Resolves: rdar://154808850
(cherry picked from commit bb0cd6f0a6)
2025-07-02 14:25:02 -07:00
Hamish Knight
ce273f4527 [Sema] Downgrade an ASSERT for 6.2 2025-07-02 21:30:31 +01:00
Hamish Knight
a9d72fb695 [Sema] Avoid applying diagnostic hack to caller-side expression macros
We can't assume that type-checking the expression macro in the
parameter will also fail if it fails at the call site since e.g
name lookup may differ. Make sure we only apply this logic to simple
literals.

rdar://154771596
2025-07-02 21:29:32 +01:00
Hamish Knight
e0ed130019 Constify DiagnosticState::determineBehavior
Split out the state mutation into a new `updateFor`
function that we call for diagnostic emission, allowing
`DiagnosticTransaction::hasErrors` to query the behavior without
mutating any state.
2025-07-02 21:29:32 +01:00
Hamish Knight
4c6e06fed3 [AST] Use ErrorType for invalid value generic parameter
If we fail to resolve the value type for a value generic parameter,
previously we would have returned a null Type, causing crashes
downstream. Instead, return an ErrorType, leaving a null Type for
cases where the generic parameter isn't a value generic at all.

rdar://154856417
2025-07-02 21:19:45 +01:00
Hamish Knight
13118899cd NFC: Constify GenericTypeParamDeclGetValueTypeRequest's parameter 2025-07-02 21:19:45 +01:00
Ben Barham
075fc7de79 Merge pull request #82709 from bnbarham/6.2-dangling-reference
[6.2][ClangImporter] Fix dangling reference
2025-07-02 13:18:44 -07:00
Slava Pestov
14a27751e2 Concurrency: Move PackExpansionType check to swift::diagnoseNonSendableTypes()
This was added in #80220 to fix a related issue with captures of packs,
but it's even better to sink this down into diagnoseNonSendableTypes(),
so that we can handle packs in parameter position as well.

- Fixes https://github.com/swiftlang/swift/issues/82614.
- Fixes rdar://problem/154649522.
2025-07-02 15:26:13 -04:00
Artem Chikin
2f07a98aec [Dependency Scanning] On cycle via overlay, fix Clang dependency path reconstruction
The code should consider *only* clang module dependencies, instead of all dependencies.
2025-07-02 12:16:06 -07:00
Pavel Yaskevich
b353f717f5 [Concurency] Allow declarations with @isolated(any) parameters be marked as @concurrent/nonisolated(nonsending)
It's shouldn't be possible to use these attributes directly on
the function type that is `@isolated(any)` as per SE-0461 proposal
but it shouldn't preclude declarations that have parameters with
`@isolated(any)` from using them.

Resolves: rdar://154754939
(cherry picked from commit a522448e90)
2025-07-02 11:50:22 -07:00
Zachary 'Clack' Cole
305125d8a0 Merge pull request #82694 from clackary/cherrypick/autodiff-fix-link-entity-diff-witness
[6.2 🍒][AutoDiff] Use `LinkEntity::SecondaryPointer` for diff witness
2025-07-02 11:30:48 -06:00
John McCall
8686a8beb5 Merge pull request #82710 from rjmccall/nonisolated-nonsending-thunks-6.2
[6.2] Correctly forward the implicit `nonisolated(nonsending)` parameter in thunks
2025-07-02 12:01:45 -04:00
Anthony Latsis
6ddd1c95f3 Merge pull request #82664 from swiftlang/jepa2-6.2
[6.2] Sema: Fix the insertion location for conformances attributes
2025-07-02 16:51:55 +01:00
Doug Gregor
d98ab48611 Merge pull request #82670 from DougGregor/isolated-deinit-main-actor-mode-6.2
[6.2] [SE-0466] Infer isolated deinit in main-actor-by-default mode
2025-07-02 07:42:06 -07:00
Egor Zhdan
0be39efad4 [cxx-interop] Fix generated header for Swift closures using CF_OPTIONS types
If a Swift class has a field, which has a closure type, which takes an instance of a `CF_OPTIONS`/`NS_OPTIONS` type as a parameter, the reverse interop logic would generate an invalid Objective-C++ header for such type.

This was discovered with UIKit's `UIControlState` type, which is declared with `NS_OPTIONS` in Objective-C, then renamed to `UIControl.State` with API Notes, and then re-exported to Objective-C++ via the generated header.

rdar://129622886

(cherry picked from commit e95c9ecffc)
2025-07-02 14:52:15 +01:00
Egor Zhdan
fc0c350c56 Merge pull request #82688 from swiftlang/egorzhdan/6.2-void-begin-crash
🍒[cxx-interop] Do not crash for `void begin()`
2025-07-02 14:45:11 +01:00
Doug Gregor
7d10f95f6a Merge pull request #82662 from DougGregor/back-deploy-main-actor-isolated-deinit-6.2
[6.2] [SE-0371] Back-deploy support for main-actor-isolated deinit
2025-07-02 00:13:47 -07:00
John McCall
dae036ae85 Correctly forward the implicit nonisolated(nonsending) parameter in
SILGen thunks.

Also, I discovered that we don't apply nonisolated(nonsending) to
function types in the new mode. That's one for a different patch.

Fixes rdar://154401813
2025-07-02 01:54:42 -04:00
Michael Spencer
7df095f6c1 [ClangImporter] Fix dangling reference.
LookupOverloadedBinOp stores `Args` for later use, so store the
backing array on the stack instead of using a temporary.

This fixes a crash that appeared under some build configurations.

Related to rdar://154291418

(cherry picked from commit 75ac27dc3d)
2025-07-01 19:48:15 -07:00
Adrian Prantl
478d16ab5f Merge pull request #82562 from charles-zablit/charles-zablit/demangling/add-wrapper-to-6.2
🍒 [demangling] add new wrapper API
2025-07-01 16:49:16 -07:00
Nate Chandler
b730144497 [CSE] Fix combine of type_value.
The instruction has no operands but has a param type.  Hash and compare
the type and the type and the param type.

rdar://154652254
2025-07-01 14:30:59 -07:00
Pavel Yaskevich
1c501e8242 Merge pull request #82675 from xedin/rdar-153646123-6.2
[6.2][Concurrency] Forego Sendable checking if conversion doesn't change t…
2025-07-01 14:19:05 -07:00
Pavel Yaskevich
ec750efad6 Merge pull request #82674 from xedin/rdar-154695053-6.2
[6.2][Concurrency] SE-0463: `Sendable` inference on sync and async variant…
2025-07-01 13:55:08 -07:00
Pavel Yaskevich
2d06a61c49 Merge pull request #82676 from xedin/rdar-153461854-serialization-fix-6.2
[6.2][Serialization] A temporary fix for `LocatableType`
2025-07-01 10:36:28 -07:00
John McCall
eff0845360 Merge pull request #82613 from rjmccall/local-function-isolation-fixes-6.2
[6.2] Local function isolation fixes
2025-07-01 13:34:16 -04:00
Egor Zhdan
1a4176041e [cxx-interop] Do not crash for void begin()
When importing C++ methods, Swift always assumes that methods named `begin()` and `end()` are unsafe, since these methods commonly return iterator types that are inherently unsafe in Swift.

Some additional logic in Sema tries to diagnose usages of `.begin()` and `.end()` from Swift and suggest safe alternatives. That logic had a null pointer dereference bug.

rdar://153814676 / resolves https://github.com/swiftlang/swift/issues/82361
(cherry picked from commit 883ff18adb)
2025-07-01 17:38:30 +01:00
Steven Wu
7606a6982e Merge pull request #82642 from cachemeifyoucan/eng/PR-153851818-release 2025-07-01 06:23:20 -07:00
Pavel Yaskevich
9b27b45e1e [Serialization] A temporary fix for LocatableType
Gracefully handle `LocatableType` types if they show up during
serialization. This is a temporary fix until we can remove
`TransitivelyConformsTo` constraint from the solver which is
the underlying cause of the issue (see https://github.com/swiftlang/swift/pull/82541).

Resolves: rdar://153461854
(cherry picked from commit 907606ef28)
2025-07-01 00:36:46 -07:00
QuietMisdreavus
a75f94eef4 [6.2] use RespectOriginallyDefinedIn when mangling extension contexts (#82657)
- **Explanation**: USR mangling can include an extension context infix
(`AAE`) when an extended type uses `@_originallyDefinedIn` on platforms
other than the active one. This adds a check for the
`RespectOriginallyDefinedIn` flag when checking extension decls against
their extended type.
- **Scope**: Changes USR mangling in these situations so that USRs are
the same for the same code regardless of platform.
- **Issues**: rdar://152598492
- **Original PRs**: https://github.com/swiftlang/swift/pull/82348
- **Risk**: Low. The change is limited to situations where the name
mangler is already disrespecting the alternate module name, and only
additionally turns on that flag for any USR mangling.
- **Testing**: Automated tests
- **Reviewers**: @edymtt @augusto2112
2025-07-01 00:30:15 -07:00
Pavel Yaskevich
3263327653 [Concurrency] Forego Sendable checking if conversion doesn't change the global actor
`FunctionConversionExpr` is allowed to modify different attributes
of a type, sometimes it could strip `@Sendable` but keep the same
global actor attribute in place, that needs to be handled explicitly
before performing Sendable checking because in this case there is
going to be no isolation context change for arguments or results.

Resolves: rdar://153646123
(cherry picked from commit 053199eb12)
2025-07-01 00:21:07 -07:00
Doug Gregor
d9bc9a2238 Merge pull request #82655 from DougGregor/isolated-conformances-collection-literals-6.2
[6.2] [SE-0470] Check uses of isolated conformances in collection literals
2025-07-01 00:20:27 -07:00
Pavel Yaskevich
f422085b70 [Concurrency] SE-0463: Sendable inference on sync and async variants of imported APIs should match
This is a follow-up to https://github.com/swiftlang/swift/pull/82085
which made it so async variant doesn't get `@Sendable` inferred because
the proposal specified that inference should happen only on completion
handler parameter type of a synchronous variant of an imported API.

This runs into implementation issues related to thunking in some
cases were async convention expects the type of a completion handler
to match exactly for both variants of the imported API.

Resolves: rdar://154695053
(cherry picked from commit 30f0fa8d75)
2025-07-01 00:16:36 -07:00
Pavel Yaskevich
c1d96d6b7b Merge pull request #82647 from xedin/rdar-148076903-6.2
[6.2][Concurrency] Fix a crash caused by misuse of `isolated` modifier
2025-07-01 00:02:07 -07:00
Konrad `ktoso` Malawski
0eb6263b6d [6.2][Concurrency] Remove experimental @Task macro (#82622) 2025-06-30 23:02:12 -07:00
Doug Gregor
f711ecc29b [SE-0466] Infer isolated deinit in main-actor-by-default mode
Now that main-actor-isolated deinit can be back-deployed, enable
inference of isolated deinit within main-actor-by-default mode.

Implements rdar://154729369.
2025-06-30 22:04:32 -07:00
Anthony Latsis
c1ed83e95f Fix use-after-free through diagnostic argument 2025-07-01 02:58:59 +01:00
Anthony Latsis
1f28a04d29 Sema: Fix the insertion location for conformances attributes 2025-07-01 02:58:48 +01:00