Commit Graph

103491 Commits

Author SHA1 Message Date
Michael Gottesman
2066826a3d Merge pull request #82421 from gottesmm/pr-0768c1bbd539bf7437d416ffb08cc970b9b96185
[region-isolation] Fix crash due to missing visitVectorBaseAddrInst case
2025-06-24 08:56:39 -07:00
Slava Pestov
be6669b3ec Merge pull request #82446 from slavapestov/fix-rdar152509409
AST: Tweak ConformanceLookupTable::compareConformances() some more
2025-06-24 11:47:21 -04:00
Anthony Latsis
8e250f3edf Fix use-after-free through diagnostic argument 2025-06-24 15:42:44 +01:00
Erik Eckstein
0dbc63a00b Guard InlineArray addressors with feature flag
To be able to parse a recent Swift.swiftinterface file with a 6.2 compiler.
This is a follow-up fix for https://github.com/swiftlang/swift/pull/81441

rdar://154118968
2025-06-24 16:02:54 +02:00
Anthony Latsis
ad8c52237c Sema: Fix the insertion location for conformances attributes 2025-06-24 14:49:03 +01:00
Charles Zablit
e8ea37b681 remove unused API 2025-06-24 13:03:32 +01:00
Alex Azarov
b72cda2cfb [Diagnostics] Fix typo in 'overridden' warning message and identifier 2025-06-24 13:41:36 +02:00
Meghana Gupta
86bdca5bf4 Merge pull request #82354 from meg-gupta/lifetimeenum
Add lifetime dependencies on function types representing ~Escapable enum elements with ~Escapable payloads
2025-06-23 22:07:38 -07:00
Slava Pestov
8d30df5327 AST: Tweak ConformanceLookupTable::compareConformances() some more
If two conformances imply a conformance to the same marker
protocol, don't diagnose redundancy if they differ by
unavailability. Instead, allow the more available conformance
to win.

This allows declaring a type that conforms to a protocol
that inherits from SendableMetatype, followed by an
unavailable Sendable conformance on the same type.

Fixes rdar://152509409.
2025-06-23 22:54:18 -04:00
Saleem Abdulrasool
d0b34c2b67 Merge pull request #82170 from compnerd/internalise
IRGen: internalise well known types with static linking
2025-06-23 19:31:22 -07:00
Doug Gregor
0e3da0e499 Allow '@unsafe' on import declarations to silence '@preconcurrency' warning
'@preconcurrency' imports open up memory safety holes with respect to
Sendable, which are diagnosed under strict memory safety + strict
concurrency checking. Allow one to write '@unsafe' on those imports to
silence the diagnostic about it.
2025-06-23 19:06:14 -07:00
Doug Gregor
dbf7fe6aa0 Merge pull request #82426 from DougGregor/selector-objc-async
Allow #selector to reference async method in non-async code
2025-06-24 02:33:00 +02:00
Meghana Gupta
0eb32f6943 Fixes after merge conflict 2025-06-23 16:52:18 -07:00
Daniil Kovalev
644f364d3d [AutoDiff] Use LinkEntity::SecondaryPointer for diff witness (#82412)
If `LinkEntity::isTypeKind()` is true, `IRGenModule::getAddrOfLLVMVariable` assumes that we can safely call
`LinkEntity::getType()`, which does `reinterpret_cast` of `LinkEntity::Pointer` to `TypeBase *`. However, for SIL
differentiability witness, the pointer has `SILDifferentiabilityWitness *` type, which is not derived from `TypeBase`. So, such a cast is not allowed.

Just as with `ProtocolWitnessTableLazyAccessFunction` and `ProtocolWitnessTableLazyCacheVariable` link entity kinds (which are also type kinds), we should use `SecondaryPointer` instead of `Pointer` for storing payload here, while setting `Pointer` to `nullptr`.
2025-06-23 16:18:07 -07:00
Allan Shortlidge
39b6c608b0 SILGen: Reorganize code related to availability.
NFC.
2025-06-23 15:57:34 -07:00
Allan Shortlidge
91043271fa SILGen: Rename SILGenBackDeploy.cpp to SILGenAvailability.cpp.
NFC.
2025-06-23 15:57:34 -07:00
Evan Wilde
7f3fdb322d Merge pull request #82355 from etcwilde/ewilde/fbsd-cxx-interop-runtime
FreeBSD: Link C++ runtimes when Cxx interop is enabled
2025-06-23 14:21:02 -07:00
Meghana Gupta
2a2deea77b Avoid circular reference errors by adding an early bailout for imported enums 2025-06-23 13:42:55 -07:00
Meghana Gupta
adceb7abc3 Serialize/deserialize lifetime dependencies on enum elements 2025-06-23 13:42:54 -07:00
Meghana Gupta
db24b6f758 Support lifetime dependence inference on enum elements 2025-06-23 13:42:53 -07:00
Meghana Gupta
ccda38b513 [NFC] Prepare LifetimeDependenceInfo to hold EnumElementDecl* 2025-06-23 13:42:48 -07:00
Artem Chikin
39c096c388 [Dependency Scanning] Refactor 'ModuleDependenciesCache' to not hold a reference to the global 'SwiftDependencyScanningService'
While this made sense in the distant past where the scanning service provided backing storage for the dependency cache, it no longer does so and now makes for awkard layering where clients get at the service via the cache. Now the cache is a simple data structure while all the clients that need access to the scanning service will get it explicitly.
2025-06-23 13:39:43 -07:00
Artem Chikin
68883a1014 [Dependency Scanning] Refactor Swift Scanner loader to be standalone
- 'SwiftModuleScanner' will now be owned directly by the 'ModuleDependencyScanningWorker' and will contain all the necessary custom logic, instead of being instantiated by the module interface loader for each query
- Moves ownership over module output path and sdk module output path directly into the scanning worker, instead of the cache
2025-06-23 13:39:36 -07:00
Pavel Yaskevich
7ecb1fd1db [CSSimplify] Prevent missing call fix from recording fixes while matching types
We need to be very careful while matching types to test whether a
fix is applicable or not to avoid adding extraneous fixes and failing
the path early. This is a temporary workaround, the real fix would
be to let `matchTypes` to propagate `TMF_ApplyingFixes` down.

Resolves: rdar://154010220
Resolves: https://github.com/swiftlang/swift/issues/82397
2025-06-23 13:38:38 -07:00
Pavel Yaskevich
25585c07f3 Merge pull request #82386 from xedin/rdar-153922620
[Concurrency] References to `nonisolated(nonsending)` properties don't…
2025-06-23 13:38:09 -07:00
Egor Zhdan
e232273886 Merge pull request #82413 from swiftlang/egorzhdan/namespace-printer-null-crash
[cxx-interop] Fix printing of namespaces declared in bridging headers
2025-06-23 21:07:36 +01:00
Doug Gregor
c34f81e110 Allow #selector to reference async method in non-async code
Fixes rdar://153118331
2025-06-23 12:41:18 -07:00
Egor Zhdan
c6d9b846b6 Merge pull request #82411 from swiftlang/egorzhdan/dead-code
[cxx-interop] NFC: Remove unused function
2025-06-23 20:14:12 +01:00
stzn
660263cf2c [region-isolation] Fix crash due to missing visitVectorBaseAddrInst case
Credit to https://github.com/stzn for initial work on the patch.

rdar://151401230
2025-06-23 11:11:59 -07:00
Pavel Yaskevich
c2388401a2 Merge pull request #82382 from xedin/rdar-153680826
[Concurrency] Don't infer `nonisolated(nonsending)` on synchronous wi…
2025-06-23 09:05:14 -07:00
Egor Zhdan
cc9c51deea [cxx-interop] Fix printing of namespaces declared in bridging headers
If a C++ namespace has redeclarations in a bridging header, printing AST for the namespace would crash the compiler. This is because such a redeclaration would not have an owning Clang module, and the AST printer did not account for that.

This change fixes the crash.

rdar://151715540
2025-06-23 16:25:48 +01:00
Egor Zhdan
4911078437 [cxx-interop] NFC: Remove unused function 2025-06-23 15:25:00 +01:00
Andrew Trick
97ddc4e3a0 Merge pull request #82404 from atrick/fix-accessor-infer
[nonescapable] remove '@_lifetime' requirement on implicit accessors
2025-06-23 07:14:43 -07:00
Slava Pestov
a9819a60ce Merge pull request #82383 from slavapestov/implied-isolated-conformance
Sema: Expand isolated conformance inference to consider conformances to inherited protocols
2025-06-23 04:00:26 -04:00
Andrew Trick
855b3e4446 [nonescapable] remove '@_lifetime' requirement on implicit accessors
This avoids diagnostic errors on synthesized accessors, which are impossible for developers to understand.

Fixes rdar://153793344 (Lifetime-dependent value returned by generated accessor '_read')
2025-06-22 23:27:09 -07:00
Slava Pestov
b0b23a070b Sema: Expand isolated conformance inference to consider conformances to inherited protocols
Otherwise, if PDerived inherits from P and P's requirements are
witnessed by @MainActor-isolated members, we fail to infer
@MainActor isolation on the conformance to PDerived.

- Fixes https://github.com/swiftlang/swift/issues/82222.
- Fixes rdar://153219831.
2025-06-22 23:21:25 -04:00
Andrew Trick
7a29d9d8b6 Fix MoveOnlyObjectCheckerPImpl::check() for mark_dependence.
Handle the presence of mark_dependence instructions after a begin_apply.

Fixes a compiler crash:
"copy of noncopyable typed value. This is a compiler bug. ..."
2025-06-22 17:39:13 -07:00
Andrew Trick
c41715ce8c Fix MoveOnlyObjectCheckerPImpl::check() changed flag
Extract the special pattern matching logic that is otherwise unrelated to the
check() function. This makes it obvious that the implementation was failing to
set the 'changed' flag whenever needed.
2025-06-22 16:38:06 -07:00
Andrew Trick
374026f344 Merge pull request #82380 from atrick/nonescapable-accessor-on-trivial
Add Feature: NonescapableAccessorOnTrivial
2025-06-21 09:24:12 -07:00
nate-chandler
17c1fbd5f4 Merge pull request #82313 from jamieQ/copy-prop-ossa-dead-ends-build-time-fix
[SILOptimizer]: slow OSSA lifetime canonicalization mitigation
2025-06-21 08:50:58 -07:00
Michael Gottesman
c3e7286f82 Merge pull request #82387 from gottesmm/pr-77ff4b6cf71ce0da4aaf358ecaa5d0ad29405276
[silgen] Make async_Main compatible with calling nonisolated(nonsending) functions.
2025-06-21 07:56:09 -07:00
eeckstein
1d3895610e Merge pull request #82349 from eeckstein/alloc-box-to-stack
Optimizer: re-implement and improve the AllocBoxToStack pass
2025-06-21 07:28:18 +02:00
Andrew Trick
cc357f4f32 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)
2025-06-20 15:59:13 -07:00
Michael Gottesman
862ef621c7 [silgen] Make async_Main compatible with calling nonisolated(nonsending) functions.
The problem is that async_Main was setting an executor as its main executor
instead of an actor. This patch fixes the issue by just grabbing the main actor
instead.

rdar://153082633
2025-06-20 15:50:27 -07:00
Michael Gottesman
aee16d7b7a Merge pull request #82375 from gottesmm/pr-4e28ed16e5bf409f1bdd07e56b1074a13efabb7d
[sema] Work around a double curry thunk actor isolation inference bug that is a knock on effect of ced96aa5cd.
2025-06-20 15:46:09 -07:00
Pavel Yaskevich
35a41ab9cf [Concurrency] References to nonisolated(nonsending) properties don't leave caller's isolation
Make sure that referencing `nonisolated(nonsending)` properties,
especially through a witness is as not treated as leaving the
isolation domain of the caller.

Resolves: rdar://153922620
2025-06-20 15:26:42 -07:00
Anthony Latsis
1ceeb7089b Merge pull request #82338 from AnthonyLatsis/jepa
ASTBridging: Bridge more enums directly
2025-06-20 23:13:50 +01:00
Ian Anderson
58cd10c045 Merge pull request #82283 from ian-twilightcoder/swift-api-digester-args
[ABIChecker] Use -Isystem and -Fsystem for swift-api-digester
2025-06-20 14:17:21 -07:00
Michael Gottesman
c28490b527 [sema] Work around a double curry thunk actor isolation inference bug that is a knock on effect of ced96aa5cd.
Specifically, there is currently a bug in TypeCheckConcurrency.cpp where we do
not visit autoclosures. This causes us to never set the autoclosure's
ActorIsolation field like all other closures. For a long time we were able to
get away with this just by relying on the isolation of the decl context of the
autoclosure... but with the introduction of nonisolated(nonsending), we found
cases where the generated single curry autoclosure would necessarily be
different than its decl context (e.x.: a synchronous outer curry thunk that is
nonisolated that returns an inner curry thunk that is
nonisolated(nonsending)). This problem caused us to hit asserts later in the
compiler since the inner closure was actually nonisolated(nonsending), but we
were thinking that it should have been concurrent.

To work around this problem, I changed the type checker in
ced96aa5cd to explicitly set the isolation of
single curry thunk autoclosures when it generates them. The reason why we did
this is that it made it so that we did not have to have a potential large source
break in 6.2 by changing TypeCheckConcurrency.cpp to visit all autoclosures it
has not been visiting.

This caused a follow on issue where since we were now inferring the inner
autoclosure to have the correct isolation, in cases where we were creating a
double curry thunk for an access to a global actor isolated field of a
non-Sendable non-global actor isolated nominal type, we would have the outer
curry thunk have unspecified isolation instead of main actor isolation. An
example of this is the following:

```swift
class A {
  var block:  @MainActor () -> Void = {}
}

class B {
  let a = A()

  func d() {
    a.block = c // Error! Passing task isolated 'self' to @MainActor closure.
  }

  @MainActor
  func c() {}
}
```

This was unintentional. To work around this, this commit changes the type
checker to explicitly set the double curry thunk isolation to the correct value
when the type checker generates the double curry thunk in the same manner as it
does for single curry thunks and validates that if we do set the value to
something explicitly that it has the same value as the single curry thunk.

rdar://152522631
2025-06-20 10:59:54 -07:00
Pavel Yaskevich
a964282275 [Concurrency] Don't infer nonisolated(nonsending) on synchronous witnesses
If the requirement is `nonisolated(nonsending)` but witness is
synchronous, prevent actor isolation inference from requirements
because this isolation only applies to asynchronous declarations
at the moment.

Resolves: rdar://153680826
2025-06-20 10:14:05 -07:00