Commit Graph

28619 Commits

Author SHA1 Message Date
Pavel Yaskevich
6cfbafd968 [CSSimplify] VariadicGenerics: Don't attempt to wrap optional into one-element tuple
If we have a tuple with unresolved pack expansion on one side
and an optional type on the other, prevent `matchTypes` from
wrapping optional into a one-element tuple because the matching
should be handled as part of the optional injection.

Resolves: rdar://152940244
2025-06-17 18:25:22 -07:00
Pavel Yaskevich
84cb3c89ff Merge pull request #79893 from simanerush/fix-explicit-nonisolated-proto-inference
[Concurrency] Look for explicit 'nonisolated' when getting isolation from protocol conformances.
2025-06-17 15:23:26 -07:00
Hamish Knight
b37e34ea8d [Sema] Tighten up function call check in resolveKeyPathExpr
Check for `CallExpr` instead of `ApplyExpr`, we don't support
arbitrary postfix operators in key paths.
2025-06-17 23:07:46 +01:00
Pavel Yaskevich
fc573b6612 [ConstraintSystem] Guard all the performance hacks with a flag
Package the flag into `performanceHacksEnabled()` method on
`ConstraintSystem` and start using it to wrap all of the hacks
in constraint generator and the solver.
2025-06-17 13:53:05 -07:00
Pavel Yaskevich
833b6b19e9 [Frontend] Remove -disable-solver-shrink option
It's folded into a more general "disable performance hacks" one.
2025-06-17 13:52:28 -07:00
Michael Gottesman
bf78c6206b Revert "[flow-isolation] Allow for initialization of fields of a Global Actor isolated class in its nonisolated inits"
This reverts commit 501bad55a8.
2025-06-17 13:01:28 -07:00
Slava Pestov
a4bfa3f72b Merge pull request #82275 from slavapestov/more-fuzzer-fixes-2
More fuzzer fixes
2025-06-17 14:57:38 -04:00
Pavel Yaskevich
2f920ceb5a Merge pull request #82289 from xedin/rdar-145519840
[Concurrency] SE-0449: `nonisolated` on a type should prevent isolati…
2025-06-17 09:02:52 -07:00
Hamish Knight
89a7014db9 [Sema] Add null check in createMemberwiseInitParameter
The property wrapper initializer info may be null if e.g we had a
request cycle, just use the property's interface type in that case.

rdar://82899428
2025-06-17 15:16:44 +01:00
Slava Pestov
b79f2817f9 Sema: Fix MissingCallFailure::diagnoseAsError() crash with special base names 2025-06-17 09:52:04 -04:00
Slava Pestov
0d6470345b Sema: Fix crash on invalid code in isOverrideBasedOnType() 2025-06-17 09:52:04 -04:00
Slava Pestov
ef5e2861a2 Sema: Fix crash on invalid code in diagnoseDictionaryLiteralDuplicateKeyEntries() 2025-06-17 09:52:03 -04:00
Slava Pestov
8b12f8cb8e Sema: Fix null pointer dereference in LazyStoragePropertyRequest::evaluate() 2025-06-17 09:52:03 -04:00
Slava Pestov
eec924b505 Sema: Fix crash in diagnoseIfSynthesisUnsupportedForDecl() with tuple extension 2025-06-17 09:52:03 -04:00
Slava Pestov
9a01e872da Sema: Address FIXME resulting in a crash in filterProtocolRequirements() 2025-06-17 09:52:03 -04:00
Slava Pestov
908c9368ed Parse: Only accept certain literals as enum case raw values
Just checking for LiteralExpr is too broad, because Sema doesn't
know what to do with RegexLiteralExpr for example.
2025-06-17 09:19:00 -04:00
Slava Pestov
de3fb02bf5 Merge pull request #82238 from slavapestov/coding-keys-parameter-pack
Sema: Relax enum parameter pack restriction for CodingKeys
2025-06-17 07:48:35 -04:00
Pavel Yaskevich
06be7bda39 [Concurrency] SE-0449: Implied conformances to nonisolated protocols make witnesses nonisolated
Even if the requirement is stated on an isolated protocol if the
conformance is implied by a nonisolated one all of the requirements
and witnesses should be nonisolated.
2025-06-17 00:05:16 -07:00
Pavel Yaskevich
e50acbf3d5 [Concurrency] SE-0449: nonisolated on a type should prevent isolation inference from protocol requirements
If a `nonisolated` type conforms to a global-isolated protocol
the witnesses to the protocol requirements should infer the
isolation from the protocol but instead be `nonisolated`.

Resolves: rdar://145519840
2025-06-16 21:28:41 -07:00
Sima Nerush
7e42a19187 [Concurrency] Make sure to still infer global actor if the conformance kind is explicit. 2025-06-16 13:59:15 -07:00
Sima Nerush
4fca62a771 [Concurrency] Look for explicit 'nonisolated' when getting isolation from protocol conformances. 2025-06-16 13:59:15 -07:00
Pavel Yaskevich
64404f5b7d Merge pull request #82229 from xedin/rdar-152689053
[Concurrency] NonisolatedNonsendingByDefault: Except `@Test` test-cases and `$` prefixed declarations from migration
2025-06-16 13:42:17 -07:00
Hamish Knight
060c9f4c5f Merge pull request #82237 from hamishknight/cod-cycle
[Sema] Scale back CodingKeys hack in `TypeChecker::lookupUnqualifiedType`
2025-06-16 20:37:35 +01:00
Pavel Yaskevich
17976c7775 [Concurrency] NonisolatedNonsendingByDefault: Don't attempt to migrate $ prefixed declarations
These are special declarations that are synthesized by the compiler
or a macro and warnings about them are non-actionable.
2025-06-13 14:36:41 -07:00
Pavel Yaskevich
f2f5d234dc [Concurrency] NonisolatedNonsendingByDefault: Don't attempt to migrate swift-testing test cases
The execution of these functions is controlled by the testing
framework and it's okay if their behavior changes when the feature
flag is enabled.

Resolves: rdar://152687527
2025-06-13 14:36:35 -07:00
Slava Pestov
9a101ca8f6 Sema: Relax enum parameter pack restriction for CodingKeys 2025-06-13 14:54:44 -04:00
Slava Pestov
84997b47ef Sema: Protocols don't have implicit members 2025-06-13 14:54:43 -04:00
Hamish Knight
6fd128ff67 [Sema] Scale back CodingKeys hack in TypeChecker::lookupUnqualifiedType
I previously added this hack to match the logic in
`TypeChecker::lookupUnqualified`, but it turns out that can introduce
request cycles for cases where `CodingKeys` is used in a generic
requirement for one of `Codable`'s potential value witnesses. Scale
back the hack such that it's only done when we get an initial empty
lookup result, ensuring we maintain source compatibility. Both these
lookup hacks should go away once we properly handle CodingKeys 
synthesis.

rdar://153096639
2025-06-13 19:42:48 +01:00
Hamish Knight
9a0a831b01 Merge pull request #82147 from hamishknight/fix-nested-arenas
[CS] Avoid solver-allocated inputs with `typesSatisfyConstraint`
2025-06-13 16:53:51 +01:00
Pavel Yaskevich
f0502c2257 [Concurrency] NonisolatedNonsendingByDefault/NFC: Move 'same module' check higher
This is a follow-up to https://github.com/swiftlang/swift/pull/82173
which moves the check higher to make it an early exist.
2025-06-12 10:40:31 -07:00
Pavel Yaskevich
5e17762b22 Merge pull request #82173 from xedin/rdar-152687353
[Concurrency] NonisolatedNonsendingByDefault: Migration applies only to the current module declarations
2025-06-12 10:18:59 -07:00
Pavel Yaskevich
bbe1185d85 Merge pull request #82157 from xedin/rdar-143581268
[TypeChecker] Remove `@_inheritActorContext` effect from synchronous …
2025-06-12 08:34:58 -07:00
Hamish Knight
6d0da8d5cc [CS] Avoid solver-allocated inputs with typesSatisfyConstraint
Escaping solver-allocated types into a nested allocation arena is
problematic since we can e.g lazily compute the `ContextSubMap` for a
`NominalOrBoundGenericNominalType`, which is then destroyed when we
exit the nested arena. Ensure we don't pass any types with type
variables or placeholders to `typesSatisfyConstraint`.

rdar://152763265
2025-06-12 12:11:19 +01:00
Hamish Knight
080b3fa55f [CS] Remove UnresolvedType ranking logic
We should never end up here, we should have placeholder bindings
instead for holes.
2025-06-12 12:11:19 +01:00
Hamish Knight
71d20b7635 [CS] NFC: Remove FreeTypeVariableBinding::UnresolvedType
This is now unused.
2025-06-12 12:11:19 +01:00
Slava Pestov
63a5731da1 Sema: Try to bind extensions without expanding macros
Macro expansion can call typeCheckExpr(), which performs qualified
lookups. So if we expand macros while binding extensions, these
qualified lookups can fail because they cannot find members of
extensions that have not been bound yet.

To fix this, try binding extensions without performing macro
expansion first. If any extensions remain at the end, we fall back
to the old behavior, and try to bind them again, this time
performing macro expansion.

Fixes rdar://149798059.
2025-06-11 20:07:43 -04:00
Slava Pestov
71186eb07f AST: Call setExtendedNominal() instead of cacheOutput(ExtendedNominalRequest...) 2025-06-11 20:07:42 -04:00
Alexis Laferrière
89f7ebfb18 Sema: @cdecl functions C name defaults to the Swift name 2025-06-11 12:42:38 -07:00
Pavel Yaskevich
bcd6caaea4 [Concurrency] NonisolatedNonsendingByDefault: Migration applies only to the current module declarations
Prevent migration from handling declarations that come from a
module different from the current one, this is primarily a
problem for swiftinterfaces that can get rebuilt when the module
is imported by a model that has migration mode enabled.

Resolves: rdar://152687353
2025-06-11 00:06:38 -07:00
Slava Pestov
7bbb29938e AST: Remove no longer necessary checks of getSuperclassForDecl() result 2025-06-10 16:49:57 -04:00
Pavel Yaskevich
dbe19b6d5f [TypeChecker] Remove @_inheritActorContext effect from synchronous types
The compiler would previously accept use of `@_inheritActorContext`
on a parameter with a synchronous function type which wasn't marked
as `@isolated(any)`. That is incorrect because in such cases the
attribute has no effect and furthermore would prevent Sendable
and isolation checking.

Uses like that are currently diagnosed by the type-checker but we
need to go one step further and remove the effect in such case to
prevent invalid uses.

Resolves: rdar://143581268
2025-06-10 10:15:37 -07:00
Meghana Gupta
7d454533a0 Merge pull request #82067 from meg-gupta/lifetimeunderscored
Update spelling for representing lifetime dependencies to @_lifetime
2025-06-09 19:01:31 -07:00
Alexis Laferrière
6d091123f9 Sema: Type-check @cdecl enums
@cdecl enums are Swift enums representable in C. These enums must have
an integer raw type. They can be referenced from @cdecl functions and
@objc methods. @objc enums are still rejected from @cdecl functions.
2025-06-09 11:54:13 -07:00
Pavel Yaskevich
a5d92bc346 Merge pull request #82053 from xedin/rdar-150689994
[Diagnostics] Correctly diagnose situations when immutable value is passed to `inout` parameter
2025-06-09 00:12:13 -07:00
Meghana Gupta
dcf072f9d0 Introduce a new suppressible experimental feature to guard @_lifetime 2025-06-07 12:49:07 -07:00
Meghana Gupta
0dfa1fc312 Update spelling for representing lifetime dependencies to @_lifetime 2025-06-07 12:49:07 -07:00
Anthony Latsis
d10dfb3ae9 Merge pull request #82020 from AnthonyLatsis/camellia-sinensis
Sema: Never record argument label mismatches for unlabeled trailing closures
2025-06-07 01:29:54 +01:00
Pavel Yaskevich
6bbc101a98 [Diagnostics] Correctly diagnose situations when immutable value is passed to inout parameter
Currently the note is going to point to the "callee" but that is
incorrect when the failure is related to an argument of a call.

Detect this situation in `RValueTreatedAsLValueFailure::diagnoseAsNote`
and produce a correct note.

Resolves: rdar://150689994
2025-06-06 14:36:19 -07:00
Pavel Yaskevich
aa92bcf9b0 Merge pull request #82004 from xedin/rdar-151911135
[Concurrency] Fix `SendableMetatype` conformance failures to behave l…
2025-06-06 14:07:55 -07:00
John McCall
237e617fab Merge pull request #82008 from rjmccall/dont-copy-print-options
Prevent PrintOptions from being implicitly copied
2025-06-06 17:06:02 -04:00