Commit Graph

184973 Commits

Author SHA1 Message Date
Hamish Knight
62c886e13b Merge pull request #82410 from hamishknight/fuzzy
[test] Add some more known type-checker crashers
2025-06-23 17:54:23 +01:00
Max Desiatov
64a8c58466 Track Wasm-related build-script files in CODEOWNERS (#82366)
Wasm-related changed should be tracked in `CODEOWNERS`, and we have separate `build-script` Python modules to include in that list.
2025-06-23 17:36:49 +01:00
Andrew Trick
934aad80f0 Merge pull request #82408 from atrick/fix-immortal
Fix lifetime dependence diagnostics on Void types.
2025-06-23 09:05: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
Alastair Houghton
0d14682f99 [Concurrency] Rename Dummy(Main|Task)Executor.
`UnimplementedExecutor` seems like a better name.

rdar://153531418
2025-06-23 16:47:50 +01:00
Saleem Abdulrasool
104eb77272 Runtimes: adjust for incorrect Android behaviour
The runtime mixes `swift` and `swift_static` SDK layouts when building
Swift code on Android. The overlay is always referenced in `swift` and
never from `swift_static`. Adjust the layout to match the driver.
2025-06-23 08:40:43 -07:00
Saleem Abdulrasool
e55af870ce utils: adopt SwiftCore_DIR in new builds
Rather than pass along build configuration context to the subsequent
builds, wire together the CMake configuration to the builds to allow
building the runtime properly.
2025-06-23 08:39:59 -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
Doug Gregor
96297e61ee Make the mangling grammar a little more regular
A few cleanups:
- Fix some comments
- Remove redundant rules
- Make sure every term is defined
- Don't use '|'; write it out as a term
2025-06-23 07:05:39 -07:00
Hamish Knight
aec446521a [test] Add some more known type-checker crashers 2025-06-23 10:05:22 +01:00
Slava Pestov
17cbe28e9d Merge pull request #82405 from slavapestov/missing-test-case
Sema: Add missing test case for #82129
2025-06-23 04:07:19 -04: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
36d2b5bee4 Fix lifetime dependence diagnostics on Void types.
Allow a dependence on Void to be considered immortal. This is the ultimate
override in cases where no other code pattern is supported yet.
2025-06-23 00:33:57 -07:00
Andrew Trick
bcc4a78c42 Fix lifetime diagnotics on an empty tuple.
Consider an empty tuple to be a value introducer rather than a forwarding
instruction.

Fixes rdar://153978086 ([nonescapable] compiler crash with dependency on an
expression)
2025-06-23 00:19:21 -07:00
Allan Shortlidge
897e14aec9 Merge pull request #82192 from tshortli/safe-stdlib
stdlib: Fix missing `unsafe` operators in more places
2025-06-22 23:28:57 -07: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
Andrew Trick
a8da66a82e Fix MarkDependenceInst.simplify()
Do not eliminate a mark_dependence on a begin_apply scope even though the token
has a trivial type.

Ideally, token would have a non-trivial Builtin type to avoid special cases.
2025-06-22 23:25:26 -07:00
Yuta Saito
9488df15e0 Merge pull request #82393 from wti/wasmkit-universal-fix-82390
Update wasmkit toolchain build to emit universal binary on macOS to fix #82390
2025-06-23 13:58:09 +09:00
Slava Pestov
22cdba4a59 Sema: Add missing test case for 63a5731da1 2025-06-22 23:23:49 -04: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
Allan Shortlidge
008efc432f stdlib: Fix missing unsafe operators in more places.
Add `unsafe` where it is still missing. I missed these in previous passes due
to conditional compilation.
2025-06-22 18:46:57 -07: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
Max Desiatov
bac080ef70 presets: allow incremental rebuilds of stdlib for WASI (#82364)
This allows quickly rebuilding and testing wasm stdlib end-to-end without rebuilding the whole toolchain.
2025-06-22 04:04:16 -07:00
Rauhul Varma
acbdfef4f4 Remove stale embedded swift documentation (#82395)
Update in-tree markdown files with links to the new Embedded Swift
documentation home.
swift-DEVELOPMENT-SNAPSHOT-2025-06-22-a
2025-06-21 19:24:55 -07:00
Max Desiatov
9b9db58b21 Discover embedded tests when testing wasmstdlib.py (#82376)
Embedded tests are only included in test discovery for `wasmstdlib` product, a separate change is needed to mark relevant tests as supported.

Without this change:

```
[2025-06-21T00:53:52.507Z] --- Running tests for wasmstdlib ---
[...]
[2025-06-21T00:59:22.874Z] Total Discovered Tests: 1405
[2025-06-21T00:59:22.874Z]   Excluded         :   2 (0.14%)
[2025-06-21T00:59:22.874Z]   Unsupported      : 725 (51.60%)
[2025-06-21T00:59:22.874Z]   Passed           : 674 (47.97%)
[2025-06-21T00:59:22.874Z]   Expectedly Failed:   4 (0.28%)
[...]
[2025-06-20T17:42:41.045Z] Build Percentage 	 Build Duration (sec) 	 Build Phase
[2025-06-20T17:42:41.045Z] ================ 	 ==================== 	 ===========
[...]
[2025-06-21T02:02:24.048Z] 3.0%              	 324.31                	 Running tests for wasmstdlib
```

With this change:

```
[2025-06-20T16:33:58.389Z] --- Running tests for wasmstdlib ---
[...]
[2025-06-20T16:39:29.285Z] Total Discovered Tests: 1626
[2025-06-20T16:39:29.285Z]   Excluded         :   2 (0.12%)
[2025-06-20T16:39:29.285Z]   Unsupported      : 946 (58.18%)
[2025-06-20T16:39:29.285Z]   Passed           : 674 (41.45%)
[2025-06-20T16:39:29.285Z]   Expectedly Failed:   4 (0.25%)
[...]
[2025-06-20T17:42:41.045Z] Build Percentage 	 Build Duration (sec) 	 Build Phase
[2025-06-20T17:42:41.045Z] ================ 	 ==================== 	 ===========
[...]
[2025-06-20T17:42:41.045Z] 3.0%              	 322.87                	 Running tests for wasmstdlib
```
2025-06-21 13:47:55 -07:00
wti
65302367d0 Update wasmkit toolchain build to emit universal on macOS to fix #82390
[platform_args] has platform variants of SwiftPM wasmkit build command:
- unchanged: non-macOS + set_installation_rpath -> rpath config
- added: macOS -> universal binaries using --arch

side effect ok?: binary path changes are captured by '--show-bin-path'
2025-06-21 11:20:40 -07:00
Andrew Trick
374026f344 Merge pull request #82380 from atrick/nonescapable-accessor-on-trivial
Add Feature: NonescapableAccessorOnTrivial
swift-DEVELOPMENT-SNAPSHOT-2025-06-21-a
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
Hamish Knight
19af3bc295 Merge pull request #82332 from hamishknight/fuzzy
[test] Add some more known type-checker crashers
swift-DEVELOPMENT-SNAPSHOT-2025-06-20-a
2025-06-20 18:35:14 +01: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
Anthony Latsis
dd78cd6dbe ASTBridging: Bridge swift::PlatformKind directly 2025-06-20 16:46:03 +01:00
Anthony Latsis
de46b95e7e ASTBridging: Bridge swift::GenericTypeParamKind directly 2025-06-20 16:46:03 +01:00
Anthony Latsis
dcbf2781c5 ASTBridging: Bridge swift::RequirementReprKind directly 2025-06-20 16:46:03 +01:00
Anthony Latsis
69a27e1735 ASTBridging: Bridge swift::LayoutConstraintKind directly 2025-06-20 16:46:03 +01:00
Anthony Latsis
b347aedeb0 ASTBridging: Encapsulate some operations on BridgedLayoutConstraint
NB: Switching from factory methods to initializers as well crashes on
Windows.
2025-06-20 16:44:49 +01:00
Adrian Prantl
267d063599 Merge pull request #82325 from adrian-prantl/153687085
[RemoteInspection] Change RemoteAbsolutePointer (NFC)
2025-06-20 08:18:47 -07:00
Charles Zablit
479e664a04 add new methods to the NodePrinter to enable range tracking possibilities when demangling a name 2025-06-20 15:30:19 +02:00
Hamish Knight
3c8a8a860a Merge pull request #82292 from hamishknight/bigger-hammer
[AST] Replace type variables and placeholders in original ErrorTypes
2025-06-20 10:59:24 +01:00