Commit Graph

185384 Commits

Author SHA1 Message Date
Max Desiatov
655a3b1e61 Merge branch 'main' into maxd/build-script-typing 2025-07-08 11:47:15 +01:00
Saleem Abdulrasool
b37d0f668f Merge pull request #82856 from Steelskin/fabrice/fix-static-foundation-link-static-dispatch
utils: Link static Foundation with static Dispatch
2025-07-08 01:48:57 -07:00
Konrad `ktoso` Malawski
fe86091cc1 Merge pull request #82558 from ktoso/wip-cleanup-group-docs 2025-07-08 01:06:51 -07:00
Hamish Knight
5cbdcaf655 Merge pull request #82834 from hamishknight/fuzzy
[test] Add some more known crashers
2025-07-08 08:32:52 +01:00
Max Desiatov
a073e6610e Merge pull request #82839 from MaxDesiatov/maxd/wasmkit-with-host-tools
For small local incremental builds that require WasmKit it's faster to build WasmKit with the host toolchain instead of waiting for a full bootstrap build to complete.
2025-07-08 08:10:40 +01:00
Pavel Yaskevich
785e7b1571 Merge pull request #82858 from gottesmm/rdar154969621
[concurrency] Perform some fixes so that transfernonsendable_closureliterals_isolationinference.swift now passes.
2025-07-08 00:04:14 -07:00
Pavel Yaskevich
dab6f3d12e Merge pull request #82807 from xedin/se-0487-implementation-adjustments
[AST/Sema] SE-0487: Adjust implementation based on the LSG feedback
2025-07-08 00:03:36 -07:00
Pavel Yaskevich
1c546e93fa Merge pull request #82857 from xedin/inheritActorContext-and-nonisolated-nonsending
[Concurrency] Prevent use of `nonisolated(nonsending)` and `@concurrent`
2025-07-08 00:03:23 -07:00
Konrad `ktoso` Malawski
e9a35c0003 Merge pull request #82865 from ktoso/wip-stronger-assert 2025-07-08 15:38:34 +09:00
Hamish Knight
8b3cb86d7f Merge pull request #82802 from hamishknight/context-fail
[Completion] Map failable initializer result type into context
2025-07-08 06:20:17 +01:00
Hamish Knight
163f097535 Merge pull request #82836 from hamishknight/cache-clear
[IDE] Make sure to clear cached CI when `CachedCIShouldBeInvalidated`
2025-07-08 06:09:48 +01:00
Doug Gregor
cee2aeadbb Merge pull request #82846 from DougGregor/isolated-conformance-to-sendablemetatype-proto-error
[SE-0470] Promote isolated-conformance-to-sendable-metatype protocol to an error
2025-07-07 21:06:47 -07:00
Slava Pestov
e67be5c683 Merge pull request #82690 from slavapestov/fix-rdar116938972
Sema: Improve the 'protocol method can't impose new requirements on Self' check
2025-07-07 23:25:58 -04:00
Konrad `ktoso` Malawski
c6f223f57a Merge pull request #82793 from ktoso/wip-correct-isolated-handling-with-caller-isolation 2025-07-08 12:01:54 +09:00
Konrad 'ktoso' Malawski
4a5ccf04a7 [Concurrency] Use ASSERT for to also assert in release builds
Small cleanup from code review; we'd crash either way after this line,
so might be better to always ASSERT more nicely.
2025-07-08 10:03:41 +09:00
Cassie Jones
f7ccb5298f Merge pull request #82714 from porglezomp-misc/update-checkout-additional-scheme
update-checkout: Support specifying --config multiple times
2025-07-07 17:31:46 -07:00
Michael Gottesman
648bb8fe30 [concurrency] Perform some fixes so that transfernonsendable_closureliterals_isolationinference.swift now passes.
The reason why this failed is that concurrently to @xedin landing
79af04ccc4, I enabled
NonisolatedNonsendingByDefault on a bunch of other tests. That change broke the
test and so we needed to fix it.

This commit fixes a few issues that were exposed:

1. We do not propagate nonisolated(nonsending) into a closure if its inferred
context isolation is global actor isolated or if the closure captures an
isolated parameter. We previously just always inferred
nonisolated(nonsending). Unfortunately since we do not yet have capture
information in CSApply, this required us to put the isolation change into
TypeCheckConcurrency.cpp and basically have function conversions of the form:

```
(function_conversion_expr type="nonisolated(nonsending) () async -> Void"
   (closure_expr type="() async -> ()" isolated_to_caller_isolation))
```

Notice how we have a function conversion to nonisolated(nonsending) from a
closure expr that has an isolation that is isolated_to_caller.

2. With this in hand, we found that this pattern caused us to first thunk a
nonisolated(nonsending) function to an @concurrent function and then thunk that
back to nonisolated(nonsending), causing the final function to always be
concurrent. I put into SILGen a peephole that recognizes this pattern and emits
the correct code.

3. With that in hand, we found that we were emitting nonisolated(nonsending)
parameters for inheritActorContext functions. This was then fixed by @xedin in

With all this in hand, closure literal isolation and all of the other RBI tests
with nonisolated(nonsending) enabled pass.

rdar://154969621
2025-07-07 17:21:41 -07:00
Pavel Yaskevich
e032f33cfb [Concurrency] Prevent use of nonisolated(nonsending) and @concurrent on @_inheritActorContext parameters
`@_inheritActorContext` is a form of isolation which precludes
direct use of inference of `nonisolated(nonsending)` and `@concurrent`
just like other isolation attributes/modifiers would i.e. `isolated`
or `@isolated(any)`.
2025-07-07 17:21:41 -07:00
Pavel Yaskevich
e42ac61d9f [Concurrency] Prevent use of nonisolated(nonsending) and @concurrent on @_inheritActorContext parameters
`@_inheritActorContext` is a form of isolation which precludes
direct use of inference of `nonisolated(nonsending)` and `@concurrent`
just like other isolation attributes/modifiers would i.e. `isolated`
or `@isolated(any)`.
2025-07-07 17:13:28 -07:00
Pavel Yaskevich
2b05dc630b Merge pull request #82833 from xedin/remove-startSynchronously
[Concurrency] Remove deprecated `Task.startSynchronously` API
2025-07-07 16:47:15 -07:00
Artem Chikin
2c1b596c73 Merge pull request #82460 from artemcm/ScanDepsDiagnoseOnlyIncompatibleCandidates
[Dependency Scanning] Diagnose an error when only finding incompatible Swift binary modules
2025-07-07 16:28:16 -07:00
Fabrice de Gans
59bf7424bc utils: Link static Foundation with static Dispatch
Previously, the static Foundation build was linking against the dynamic
Dispatch build, resulting in a build failure when linking against the
static Foundation. This fixes the issue by linking the static Foundation
build against the static Dispatch build.
2025-07-07 14:38:16 -07:00
Guillaume Lessard
9d179716f8 Merge pull request #82828 from glessard/mutableSpan-extractingBug
[stdlib] fix some unsafe errors
2025-07-07 14:28:18 -07:00
Joe Groff
8a817da6d8 Merge pull request #82707 from jckarter/afd-clang-imports
Lower imported C structs and unions as addressable-for-dependencies.
2025-07-07 13:23:49 -07:00
Pavel Yaskevich
6e8287c29e Merge pull request #82835 from al45tair/eng/PR-155054460
[Concurrency] Don't use ExecutorJob for task-to-thread model.
2025-07-07 12:13:33 -07:00
Cassie Jones
f3917b340e update-checkout: Support specifying --config multiple times
Passing additional --config flags will load each config file in turn and
uses the last value for any defined config. This allows having local
configs that only define personal schemes and still having access to the
default schemes. This also makes it easier to work with machine
generated configs without having to cause churn in the main config file.
2025-07-07 11:48:54 -07:00
Egor Zhdan
569ca005e8 Merge pull request #82680 from swiftlang/egorzhdan/enable-c-frt
[cxx-interop] Enable foreign reference types in C interop
2025-07-07 19:42:06 +01:00
Doug Gregor
56e38b33b6 [SE-0470] Promote isolated-conformance-to-sendable-metatype protocol to error
Forming an isolated conformance to a SendableMetatype-inherting
protocol opens up a soundness hole any time the conformance is used.
Reword the recently-introduced diagnostic for this case and promote it
to an error (except when it's preconcurrency).

Fixes rdar://154808002.
2025-07-07 11:35:19 -07:00
Artem Chikin
8961d8da9a [Dependency Scanning] Diagnose an error when only finding incompatible Swift binary modules
When querying a Swift module, the scanner now also keeps track of all discovered candidate binary modules which are not compatible with current compilation.

- If a Swift dependency is successfully resolved to a compatible binary module or a textual interface, a warning is emitted for every incompatible binary Swift module discovered along the way.
- If a Swift dependency is not resolved, but incompatible module candidates were found, an error is emitted - while it is likely that the scan would fail downstream, it is also possible that an underlying Clang module dependency (with the same name) is successfuly resolved and the Swift lookup failure is ignored, which is still going to lead to failures most of the time if the client code assumes the presence of the Swift overlay module in this scenario.

This change refactors common error reporting by the scanner into a 'ModuleDependencyIssueReporter' class, which also keeps track of all diagnosed failed lookups to avoid repeating diagnostics.
2025-07-07 11:11:34 -07:00
Artem Chikin
d499b14cb3 Merge pull request #82751 from artemcm/FixDepScanCxxStdlibLookup
[Dependency Scanning][C++ Interop] Do not skip lookup of 'CxxStdlib' overlay for the source module
2025-07-07 10:52:28 -07:00
Artem Chikin
b889976dc9 Merge pull request #82695 from artemcm/DepScanCycleShadow
[Dependency Scanning] Emit a note if a dependency cycle is between the source target and another Swift module with the same name
2025-07-07 10:52:14 -07:00
Slava Pestov
4dc0db31f9 Sema: Improve the 'protocol method can't impose new requirements on Self' check
This check had two problems. First, it would assert upon encountering
a layout requirement, due to an unimplemented code path.

A more fundamental issue is that the logic wasn't fully sound, because
it would miss certain cases, for example:

    protocol P {
      associatedtype A

      func run<B: Equatable>(_: B) where B == Self.A
    }

Here, the reduced type of `Self.A` is `B`, and at first glance, the
requirement `B: Equatable` appears to be fine. However, this
is actually a new requirement on `Self`, and the protocol be rejected.

Now that we can change the reduction order by assigning weights to
generic parameters, this check can be implemented in a better way,
by building a new generic signature first, where all generic
parameters introduced by the protocol method, like 'B' above, are
assigned a non-zero weight.

With this reduction order, any type that is equivalent to
a member type of `Self` will have a reduced type rooted in `Self`,
at which point the previous syntactic check becomes sound.

Since this may cause us to reject code we accepted previously,
the type checker now performs the check once: first on the original
signature, which may miss certain cases, and then again on the new
signature built with the weighted reduction order.

If the first check fails, we diagnose an error. If the second
check fails, we only diagnose a warning.

However, this warning will become an error soon, and it really
can cause compiler crashes and miscompiles to have a malformed
protocol like this.

Fixes rdar://116938972.
2025-07-07 12:23:58 -04:00
Max Desiatov
4a8871f94b Respect --build-runtime-with-host-compiler in wasmkit.py 2025-07-07 15:21:51 +01:00
Max Desiatov
03dd520646 Add swift_build/swift-build to swift_build_support/toolchain.py
This exposes `swift-build` from toolchains, which allows products to use this tool directly when building
2025-07-07 15:16:52 +01:00
Daniil Kovalev
5528cf1cc4 [AutoDiff] Run AutoDiff closure spec pass for all VJPs (#81548)
Previously, AutoDiff closure specialization pass was triggered only on
VJPs containing single basic block. However, the pass logic allows
running on arbitrary VJPs. This PR enables the pass for all VJPs
unconditionally. So, if the pullback corresponding to multiple-BB VJP
accepts some closures directly as arguments, these closures might become
specialized by the pass. Closures passed via payload of branch tracing
enum are not specialized - this is subject for future changes.

The PR contains several commits.
1. The thing named "call site" in the code is partial_apply of pullback
corresponding to the VJP. This might appear only once, so we drop
support for multiple "call sites".
2. Enhance existing SILOptimizer tests for the pass.
3. Add validation-tests for single basic block case.
4. The change itself - delete check against single basic block.
5. Add validation-tests for multiple basic block case.
6. Add SILOptimizer tests for multiple basic block case.
2025-07-07 13:00:14 +00:00
Hamish Knight
2b1c82f498 [IDE] Make sure to clear cached CI when CachedCIShouldBeInvalidated
`performNewOperation` may not set a new compiler instance if e.g it
ends up being cancelled, so we need to make sure we reset the cached
compiler instance to ensure future requests don't attempt to re-use
it. Noticed by inspection.
2025-07-07 12:08:42 +01:00
Alastair Houghton
79f746e62d [Concurrency] Don't use ExecutorJob for task-to-thread model.
Task-to-thread model doesn't have `ExecutorJob`, so we can't use it;
however, we probably also don't need `_swift_createJobForTestingOnly`
there so just `#if` it out in that case.

rdar://155054460
2025-07-07 11:43:53 +01:00
Hamish Knight
5730eb2e10 [test] Add some more known crashers 2025-07-07 11:12:36 +01:00
Hamish Knight
1169376fda Add swift-ide-test option for source-order batch completion 2025-07-07 11:12:36 +01:00
Guillaume Lessard
36b5090a98 Merge pull request #82598 from glessard/rdar153654652-now-available
[stdlib] add `span` properties to the backdeployment library
2025-07-07 02:46:10 -07:00
Guillaume Lessard
9ac65cf735 [stdlib] fix some unsafe errors 2025-07-07 02:29:51 -07:00
Allan Shortlidge
d9d4fecc79 Merge pull request #82773 from tshortli/refactor-availability-query-silgen
SILGen: Generalize availability query emission
2025-07-07 00:46:22 -07:00
Pavel Yaskevich
e108524d98 [Concurrency] Remove deprecated Task.startSynchronously API
This is the original spelling which was not accepted. We kept
it for a bit to give adopters time to switch but it's time to
remove it now.
2025-07-07 00:31:19 -07:00
Allan Shortlidge
6e08b8980f SILGen: Refactor emission of availability checks.
Generalize SILGen for `if #available` checks by delegating the determination of
the query function and its arguments to `AvailabilityQuery`. Update SILGen for
`@backDeployed` thunks to use the same infrastructure.

NFC.
2025-07-06 19:44:53 -07:00
Allan Shortlidge
a4f59f9481 AST: Return @backDeployed attribute along with version from Decl query.
Also, introduce a convenience on `BackDeployedAttr` for getting its associated
`AvailabilityDomain`.

NFC.
2025-07-06 19:44:53 -07:00
Konrad 'ktoso' Malawski
b1ca06d79d [Concurrency] #isolation+nonsending nonisolated - review followup and SIL test 2025-07-07 11:37:16 +09:00
Slava Pestov
27e65732b1 Merge pull request #82785 from slavapestov/fix-rdar154684522
RequirementMachine: Increase default type differences limit to 13000
2025-07-06 16:37:43 -04:00
Saleem Abdulrasool
fa3db90ae3 Merge pull request #82191 from compnerd/static-libdispatch
utils: update experimental SDK builds
2025-07-06 10:25:54 -07:00
Doug Gregor
2e27ff8734 Merge pull request #82814 from DougGregor/region-inference-dynamic-isolated-conformances
[SE-0470] Extend region analysis to account for isolated conformances
2025-07-06 09:24:17 -07:00
Anthony Latsis
01c26004fc Merge pull request #66349 from LiamSwayne/patch-1 2025-07-06 16:25:03 +01:00