Commit Graph

1701 Commits

Author SHA1 Message Date
Meghana Gupta
1998f416a5 Merge pull request #81678 from meg-gupta/fixsubst
Fix use-after-free on substituting function type involving conditional ~Escapable with Escapable type
2025-05-27 12:47:29 -07:00
Pavel Yaskevich
9e562881fe [TypeChecker] Improve diagnostics for access to actor-isolated values outside of the actor
Replaces generic `expression is 'async' but is not marked with 'await`
diagnostic with a tailed one for cases where there is an access to an
actor-isolated value outside of its actor without `await` keyword.

This makes the diagnostics for async and sync contexts consistent
and actually identifies a problem instead of simply pointing out
the solution.

Resolves: rdar://151720646
2025-05-23 00:20:18 -07:00
Meghana Gupta
dbe548d4e1 Fix use-after-free on substituting function type involving conditional ~Escapable with Escapable type 2025-05-21 15:40:49 -07:00
Michael Gottesman
20d7a6c4c4 [sil] Update tests for witness table ABI verification. 2025-05-15 14:04:34 -07:00
Erik Eckstein
a38db6439a SIL: add the vector_base_addr instruction
It derives the address of the first element of a vector, i.e. a `Builtin.FixedArray`, from the address of the vector itself.
Addresses of other vector elements can then be derived with `index_addr`.
2025-05-12 19:24:31 +02:00
Tony Allevato
a3993f972a Merge pull request #80498 from allevato/json-usr-fixes
[AST] More JSON AST dump improvements.
2025-04-23 15:35:17 -04:00
Pavel Yaskevich
c110941c27 [Frontend] Rename AsyncCallerExecution upcoming feature to NonisolatedNonsendingBeDefault 2025-04-21 13:59:29 -07:00
Pavel Yaskevich
a3d35d54e5 [Frontend] Mark AsyncCallerExecution as an upcoming feature in Swift 7 2025-04-21 11:45:48 -07:00
Doug Gregor
f09cdc2893 Fix deserialization assertion involving isolated conformances 2025-04-13 15:42:00 -07:00
Doug Gregor
3380331e7e [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.
2025-04-13 15:41:53 -07:00
Pavel Yaskevich
f1b3c7b604 [AST] Remove ExecutionAttribute experimental feature
SE-0461 has been accepted and `@concurrent` and `nonisolated(nonsending)`
can be make generally available now.
2025-04-11 15:59:25 -07:00
Pavel Yaskevich
07ff063ae3 [AST/ASTGen/Sema/Serialization] Remove @execution attribute
Complete the transition from `@execution` to `@concurrent` and `nonisolated(nonsending)`
2025-04-11 15:59:25 -07:00
Pavel Yaskevich
4b8c8e7d72 [AST/Sema] Replace @execution(concurrent) with @concurrent 2025-04-11 12:08:29 -07:00
Allan Shortlidge
94a8526526 Merge pull request #80616 from tshortli/availability-domain-serialization
Serialization: Encode custom availability domains
2025-04-08 22:39:03 -07:00
Alexis Laferrière
52ebd4a122 Merge pull request #80550 from xymus/deser-late-shadowing
Serialization: Bring back shadowing but only after the filtering
2025-04-08 10:01:31 -07:00
Allan Shortlidge
abac42b759 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 08:53:42 -07:00
Alexis Laferrière
f4dedc32b5 Serialization: Bring back shadowing but only after the filtering
Followup fix to #80009. We can still get ambiguities from colliding
decls across modules with the deserialization filtering. Bring back
calling the general lookup shadowing after the filtering. This way it
won't use filtered out decls to hide potential candidates.

rdar://148286345
2025-04-04 13:42:42 -07:00
Meghana Gupta
ef1e94577f Revert "Merge pull request #80540 from swiftlang/revert-80452-lifetimeinout"
This reverts commit 6eaa07a880, reversing
changes made to e75ee3f4cf.
2025-04-04 09:50:13 -07:00
Artem Chikin
39e1791b67 Revert "Add support for inout lifetime dependence" 2025-04-04 09:00:09 -07:00
Meghana Gupta
364338283b [NFC] Update tests 2025-04-03 17:32:02 -07:00
Tony Allevato
fa1f82967f Also show the new conformance details in the default dump. 2025-04-03 12:37:15 -04:00
Alejandro Alonso
b5e8f495f7 Fix serialization for InlineArray sugar 2025-03-26 12:37:34 -07:00
Allan Shortlidge
3af72e4dca Serialization: Skip invalid @available attributes during lazy serialization.
When performing lazy module serialization, we may be making the first attempt
to turn an `AvailableAttr` into a `SemanticAvailableAttr`. If it turns out the
attribute is invalid at that point, we need to skip it instead of assuming
that the attribute will always be valid there.

Resolves rdar://147539902.
2025-03-21 15:45:53 -07:00
Alexis Laferrière
2086df0e17 Merge pull request #80108 from xymus/deser-protect-enum-raw-type
Serialization: Protect `deserializeEnum` and more against failures
2025-03-20 09:04:24 -07:00
Alexis Laferrière
fe9c48cc8c Serialization: Protect getType for params and classes 2025-03-19 16:25:48 -07:00
Alexis Laferrière
06d2d4cb50 Serialization: Recover from missing raw types on an enum
Recover from a raw type hidden behind an internal or implementation-only
import by dropping the whole enum when the raw type is unavailable. This
scenario should happen only when looking at non-public decl for indexing or
debugging, or if dependencies somehow changed and left behind a stale
swiftmodule file.

rdar://147091863
2025-03-19 14:10:57 -07:00
Alexis Laferrière
6358cb9024 Serialization: Update style of the test implementation-only-missing 2025-03-19 14:10:56 -07:00
Andrew Trick
64a48d08e1 Update tests for strict @lifetime type checking 2025-03-19 11:59:04 -07:00
Alexis Laferrière
7ae7371b62 Merge pull request #80009 from xymus/deser-internal-shadow
Serialization: Ignore lookup shadowing when resolving cross-references
2025-03-18 10:42:38 -07:00
Alexis Laferrière
bf224e21f3 Serialization: Add test for more shadowing scenarios in inlinable code 2025-03-14 13:35:14 -07:00
Alexis Laferrière
18eb4e43e4 Serialization: Skip lookup shadowing when resolving cross-references
When a Swift function shadows a clang function of the same name, the
assumption was that Swift code would refer only to the Swift one.
However, if the Swift function is `@usableFromInline internal` it can be
called only from the local module and inlined automatically in other
clients. Outside of that module, sources see only the clang function, so
their inlinable code calls only the clang function and ignores the Swift
one. This configuration passed type checking but it could crash the
compiler at inlining the call as the compiler couldn't see the clang
function.

Let's update the deserialization logic to support inlined calls to the
shadowed or the shadower. Typical shadowing is already handled by the
custom deserialization cross-reference filtering logic which looks for
the defining module, scope and whether it's a Swift or clang decl. We
can disable the lookup shadowing logic and rely only on the
deserialization filtering.

rdar://146320871
https://github.com/swiftlang/swift/issues/79801
2025-03-14 12:35:18 -07:00
Doug Gregor
3837661b84 [Isolated conformances] Allow conformance isolation to differ from the type's
With the move to explicitly specifying the global actor for an isolated
conformance, we can now have conformances whose isolation differs from
that of the type, including having actors with global-actor-isolated
conformances. Introduce this generalization to match the proposal, and
update/add tests accordingly.
2025-03-12 23:18:28 -07:00
Doug Gregor
0e873e723c [Isolated conformances] Change syntax to @<global actor type> P
Instead of using the `isolated P` syntax, switch to specifying the
global actor type directly, e.g.,

   class MyClass: @MainActor MyProto { ... }

No functionality change at this point
2025-03-12 23:18:10 -07:00
Alexis Laferrière
c0a4056768 Merge pull request #79851 from xymus/deser-recover-conformance-xref
Serialization: Diagnose broken conformances from stale swiftmodule files
2025-03-11 15:07:38 -07:00
Alejandro Alonso
d0513a7aec Merge pull request #79665 from Azoy/value-generics-no-more-experiment
[AST] Make ValueGenerics feature always available
2025-03-10 15:14:34 -07:00
Alexis Laferrière
fb3944f1b1 Serialization: Error on mismatch between requirements and confirmances
When deserialization a protocol conformance from a binary swiftmodule
file the compiler can encounter inconsistencies caused by stale module
files. Replace the hard crash with a proper error and print the list of
requirements and conformances being compared to stderr for manual
inspection. Recover silently when we can afford to, during indexing or
in LLDB.
2025-03-07 14:05:57 -08:00
Alexis Laferrière
ea5658eece Serialization: Protect readNormalProtocolConformanceXRef
Failures in `readNormalProtocolConformanceXRef` are usually caused by a
dependency change without the required rebuild of its dependents.
Display a proper error instead of crashing when encountering such an
issue during normal compilation. Recover silently when we can afford to,
during indexing or in LLDB.
2025-03-07 14:05:57 -08:00
Alexis Laferrière
e97db1c844 Merge pull request #79487 from xymus/limit-nserror-optimization-to-import
SILGen: Ensure Foundation is publicly imported before referencing `NSError` in code gen
2025-02-28 15:21:11 -08:00
Alejandro Alonso
c1bb143648 Make ValueGenerics feature always available 2025-02-27 10:03:37 -08:00
Usama Hameed
500187cf1e Add support for serializing debug_value instructions (#78056)
This patch adds support for serialization of debug value instructions. Enablement is currently gated behind the -experimental-serialize-debug-info flag.

Previously, debug_value instructions were lost during serialization. This made it harder to debug cross module inlined functions.
2025-02-24 20:21:15 -08:00
Pavel Yaskevich
dd1be8f6d4 [Frontend] Hide @execution attribute behind an experimental feature ExecutionAttribute
Since the proposal has not been approved yet we cannot expose
`@execution` attribute.
2025-02-20 00:05:03 -08:00
Pavel Yaskevich
e2ff3308be [Frontend] NFC: Rename NonIsolatedAsyncInheritsIsolationFromContext feature
New name is `AsyncCallerExecution` as stated by the proposal.
2025-02-19 20:00:56 -08:00
Michael Gottesman
3ef18eaf1d Merge pull request #79300 from gottesmm/pr-12bede947a34719b34b1aa8ea6c126a6126d6dd6
[concurrency] Implement serialization for execution(caller)/execution(concurrent).
2025-02-19 18:29:02 -08:00
Alexis Laferrière
db7126c390 SILGen: Limit references to NSError in inlinable code optimization
Revisit the optimization that provides a fast path for instances of
`NSError` when erasing the `Error` type in `emitExistentialErasure`. It
generated references to `NSError` when the `Foundation` module was
loaded, no matter how it was imported. This lead to deserialization
failures at reading the swiftmodule when that reference was added to
inlinable code while `Foundation` was not a public dependency.

Fix this crash by limiting the optimization to all non-inlinable code
and only inlinable code from a module with a public dependency on
`Foundation`. This is the similar check we apply to user written
inlinable code, however here we use the module-wide dependency instead
of per file imports.

rdar://142438679
2025-02-19 15:34:20 -08:00
Alexis Laferrière
f8722df3b9 Merge pull request #79339 from xymus/error-sil-function-cache
Tests: Use a local cache for error-sil-function.swift
2025-02-14 13:23:40 -08:00
Michael Gottesman
1fc836c564 [concurrency] Persist caller isolation inheriting through serialization.
rdar://142790023
2025-02-12 12:36:13 -08:00
Erik Eckstein
e0b4f71af6 SIL: remove the alloc_vector instruction
It's not needed anymore, because the "FixedArray" experimental feature is replaced by inline-arrays.
2025-02-12 10:51:14 +01:00
Alexis Laferrière
d6fb616047 Tests: Use a local cache for error-sil-function.swift
This test appears flaky and it looks to be related to errors on modules
in the SDK from the timing with other failures. The flackiness is likely
from non-determinism in the module cache. Update the test to use a local
cache, which is a good practice for any test importing a module from the
SDK.

rdar://144272339
2025-02-11 15:52:00 -08:00
Alex Hoppen
fc2ee364ef Merge pull request #78899 from ahoppen/rdar141440011
[Serialization] Ensure we run `InheritedTypeRequest` before serializing inherited type
2025-02-04 18:36:48 -08:00
Alexis Laferrière
6852e0b9bb Merge pull request #79092 from xymus/more-serial-remarks
Serialization: Report deserialization remarks from lookup services
2025-02-04 09:03:23 -08:00