Commit Graph

28382 Commits

Author SHA1 Message Date
Erik Eckstein
ed4863f76c Sema: don't use llvm::StringSwitch for runtime function names
Using `llvm::StringSwitch` with this many cases causes clang to crash due to a stack overflow.
Works around rdar://143944155
2025-02-03 09:54:07 +01:00
Cal Stephens
be0e68eca3 Add more test cases, simplify logic 2025-02-02 19:28:18 -08:00
Cal Stephens
f2cda5efe3 Merge tag 'swift-DEVELOPMENT-SNAPSHOT-2025-01-31-a' of github.com:swiftlang/swift into cal--fix-nested-weak-self-issue
Tag build swift-DEVELOPMENT-SNAPSHOT-2025-01-31-a
2025-02-02 14:18:15 -08:00
Allan Shortlidge
427c8affef Parse/Sema: Consolidate diagnostics for unexpected versions.
Since resolving the domain of an `@available` attribute is done during type
checking now, diagnostics about unexpected versions for a domain need to be
emitted at that point instead of during parsing. It doesn't make sense to
maintain the special version of this diagnostic that is emitted during parsing
for the universal availability domain only.
2025-02-02 09:57:43 -08:00
Slava Pestov
f35dd66b77 Revert "Sema: Don't generate OneWayEqual constraints for pattern bindings"
This reverts commit 5071e96a78.
2025-02-02 00:43:15 -05:00
Slava Pestov
5b4218c38d Revert "Sema: Remove ConstraintKind::OneWayEqual"
This reverts commit 385d66f24e.
2025-02-02 00:43:15 -05:00
Slava Pestov
fa73be2415 Revert "Sema: Remove one-way constraint handling from computeConnectedComponents()"
This reverts commit dd3e49c3ac.
2025-02-02 00:43:15 -05:00
Slava Pestov
8af183cca8 Revert "Sema: Remove DependentComponentSplitterStep"
This reverts commit 9fb6d9251e.
2025-02-02 00:43:15 -05:00
Slava Pestov
8800c3b630 Revert "Sema: Simplify depthFirstSearch() a bit now that it only has one caller"
This reverts commit 25ad700fb0.
2025-02-02 00:43:15 -05:00
Slava Pestov
99595e615e Revert "Sema: Split up gatherConstraints() into gatherAllConstraints() and gatherNearbyConstraints()"
This reverts commit 2230c3a17e.
2025-02-02 00:43:15 -05:00
Allan Shortlidge
afd99725eb Merge pull request #79070 from tshortli/model-custom-availability-domains
AST/Sema: Model custom availability domains
2025-02-01 14:09:37 -08:00
Allan Shortlidge
79c017377d Parse: Temporarily revert removal of diagnostic.
SourceKit-LSP tests depend on the exact behavior of this diagnostic (which I
don't plan to preserve) so I'm reverting the consolidation temporarily to get
unblocked.
2025-02-01 10:07:20 -08:00
Pavel Yaskevich
d245dac784 Merge pull request #79086 from xedin/small-solver-perf-optimizations
[CSOptimizer] A few small performance optimizations
2025-01-31 21:20:50 -08:00
Allan Shortlidge
1e76f19be9 Sema: Reject version specs in @available attributes for custom domains. 2025-01-31 17:31:13 -08:00
Allan Shortlidge
5c61a2d53e Sema: Require experimental feature to use custom availability domains. 2025-01-31 17:31:13 -08:00
Allan Shortlidge
770ddad742 AST/Sema: Look up custom availability domains by name.
Store the domain definitions defined on the command line on the `ModuleDecl` for
the main module.
2025-01-31 17:31:13 -08:00
Allan Shortlidge
f9799aeba9 AST: Introduce a Custom availability domain kind. 2025-01-31 17:31:07 -08:00
Pavel Yaskevich
72340f39b8 [CSOptimizer] Look through OptionalEvaluationExprs when dealing with unapplied disjunctions
This improves performance for situations like `a?.b + 2` by
giving a high score to `b` which prioritizes it over an operator.
2025-01-31 13:07:29 -08:00
Pavel Yaskevich
6bc23b5057 [CSOptimizer] Don't consider disabled overloads when checking whether disjunction is supported
Non-operator disjunctions are supported only if all of their _active_
choices are concrete.
2025-01-31 13:06:51 -08:00
Alexis Laferrière
63c2979e13 Merge pull request #78471 from xymus/fix-accessor-is-spi
Sema: Accessors's SPI are tied to the attributes on the storage
2025-01-31 08:59:43 -08:00
Anthony Latsis
d585d1658d Merge pull request #78971 from AnthonyLatsis/amorphophallus-titanum 2025-01-31 08:37:44 +00:00
Anthony Latsis
34f9b80cbc Merge pull request #78750 from AnthonyLatsis/oryza-sativa
[Gardening] Fix some set but not used variables
2025-01-31 04:29:05 +00:00
Slava Pestov
adc16beb0e Merge pull request #79061 from slavapestov/fix-rdar143707820
Sema: Fix generic type alias resolution edge case
2025-01-30 21:33:23 -05:00
Anthony Latsis
a84dfc8387 [Gardening] Fix some set but not used variables 2025-01-30 21:34:38 +00:00
Holly Borla
c4b65be753 Merge pull request #79048 from hborla/delete-infer-public-sendable-flag
[Concurrency] Remove `EnableInferPublicSendable`.
2025-01-30 20:48:40 +00:00
Slava Pestov
7c6c5fcd50 Sema: Fix generic type alias resolution edge case
If a type alias in generic context fixes all outer generic
parameters to concrete types, we allow the type alias to
be referenced without specifying the generic arguments of
its parent type.

However, we need to reduce the underlying type in case it
was written in terms of the (fully concrete) generic
parameters.

Fixes rdar://problem/143707820.
2025-01-30 15:34:10 -05:00
Holly Borla
b3275d9db3 Merge pull request #79044 from hborla/default-actor-isolation-fixes
[Concurrency] Two isolation inference changes for default isolation mode.
2025-01-30 16:36:57 +00:00
Holly Borla
430d25f7e6 [Concurrency] Remove EnableInferPublicSendable. 2025-01-30 16:10:51 +00:00
Holly Borla
28948965dd [Concurrency] Two isolation inference changes for default isolation mode.
1. Non-actor initializers should participate in custom default isolation
   inference. Otherwise, they will not be able to touch the type's stored
   properties to initialize them if those properties have the default
   isolation inferred.
2. All declarations inside actors and distributed actors do not participate
   in default isolation inference; they remain unspecified, so the existing
   isolation inference rules apply.
2025-01-30 11:54:57 +00:00
Konrad `ktoso` Malawski
dee96d9516 Merge pull request #78978 from ktoso/wip-fix-error-type-distributed-throws 2025-01-30 11:36:23 +00:00
Pavel Yaskevich
aff0f455cf Merge pull request #79026 from xedin/rdar-143474313
[CSBindings] Allow optional subtype inference when closure result is …
2025-01-30 00:37:46 -08:00
Pavel Yaskevich
f5158f8427 Merge pull request #79023 from xedin/rdar-143799118
[CSOptimizer] Disjunctions with IUO overload choices are unsupported
2025-01-30 00:37:33 -08:00
Anthony Latsis
9fb198ff71 Sema: Do not diagnose preconcurrency redundancy in implied conformances 2025-01-30 06:35:43 +00:00
Michael Gottesman
37720323d2 Merge pull request #78997 from gottesmm/wire-up-execution
[concurrency] Wire up execution(concurrent)/execution(caller)
2025-01-29 16:53:11 -08:00
Pavel Yaskevich
654d39b736 Merge pull request #79004 from xedin/rdar-143582881
[CSOptimizer] MemberImportVisibility: Don't consider overloads that c…
2025-01-29 14:23:47 -08:00
Pavel Yaskevich
c922ab5634 [CSBindings] Allow optional subtype inference when closure result is not yet resolved
Similar to `Void?` we need to unwrap `$T?` because it could be later
bound to `Void` from context.

Resolves: rdar://143474313
2025-01-29 13:12:56 -08:00
Michael Gottesman
28826b107c Remove some dead code and remove an unneeded comment. 2025-01-29 12:22:57 -08:00
Pavel Yaskevich
471ee21535 [CSOptimizer] Disjunctions with IUO overload choices are unsupported
They form a follow-up disjunction to determine whether force unwrap
is necessary and `getEffectiveType` cannot handle that.

Resolves: rdar://143799118
2025-01-29 10:36:16 -08:00
Pavel Yaskevich
aa4a2b9071 [CSOptimizer] MemberImportVisibility: Don't consider overloads that come from implicit imports
Ignore declarations that come from implicitly imported modules
when `MemberImportVisibility` feature is enabled otherwise
we might end up favoring an overload that would be diagnosed
as unavailable later.

Resolves: rdar://143582881
2025-01-29 10:09:39 -08:00
Michael Gottesman
d79fcb6d84 [caller-isolation] Teach Sema how to handle isolation of explicit @execution({concurrent,caller}). 2025-01-28 13:48:44 -08:00
Allan Shortlidge
36c6c7fc68 AST: Add a DeclContext to AvailabilityDomain::builtinDomainForString().
A context is needed to customize the behavior of lookup in downstream versions
of Swift.
2025-01-28 13:47:42 -08:00
Allan Shortlidge
4fa8c559da Sema: Fix diagnostics for @available(noasync, swift). 2025-01-28 13:47:42 -08:00
Michael Gottesman
6a9afa53f7 [concurrency] Add back support for checking if we have a global actor/execution together. 2025-01-28 13:44:23 -08:00
Michael Gottesman
3415189442 [concurrency] Change execution to override inferred global actor isolation to match nonisolated.
Specifically, we were attempting to diagnose cases like the following:

```swift
@MainActor protocol P {
  func foo() async
}

struct S : P {
  @execution(concurrent) func foo() async {}
}
```

This was just an attempt to be more conservative. After some conversations, it
came up that nonisolated does not work that way... that is the compiler will
accept the following and just hop in the protocol witness thunk:

```swift
@MainActor protocol P {
  func foo() async
}

struct S : P {
  nonisolated func foo() async {}
}
```
2025-01-28 12:46:20 -08:00
Michael Gottesman
527616d105 [sema] Move some extra type checking from getIsolationFromAttribute to the attribute checker.
This never belonged in ActorIsolationRequest since it fits perfectly in the
attribute checker. This also simplifies the logic before I add code to
getIsolationFromAttribute to handle ExecutionAttribute.
2025-01-28 12:39:05 -08:00
Konrad `ktoso` Malawski
a2b3c488a7 [Distributed] ban typed throws in distributed funcs
They don't yield a correct error type as we didn't implement it, so
rather allow it and risk crashes, ban it until we get the time to
implement it.

The real solution is to adjust typed throws error inference to do an
union of the thrown error of the func and the type thrown by the
distributed actor system remote call -- which today always would be (E |
Error) -> Error...

We could add a new associated type to DAS and then we could make it more
proper...

resolves rdar://136467528
2025-01-28 17:07:21 +00:00
Slava Pestov
852e3f5f94 Merge pull request #78957 from slavapestov/cgfloat-double-cleanup
Sema: Clean up CSApply for CGFloat <-> Double conversion
2025-01-28 08:06:32 -05:00
Anthony Latsis
b97682adc9 [NFC] Sema: Minor optimizations to TypeChecker::checkConformancesInContext 2025-01-28 08:12:41 +00:00
Pavel Yaskevich
248c0260f0 Merge pull request #78949 from xedin/rdar-143475850-part-2
[CSOptimizer] Don't consider CGFloat widening when explicit initializ…
2025-01-28 00:04:18 -08:00
Allan Shortlidge
e019a32122 AST: Introduce and adopt DeclContext::isInSwiftinterface().
Checking whether a declaration is in a `.swiftinterface` is a very common query
that is made somewhat awkward because declarations are not always in source
files. To make these checks more ergonomic, expose a convenience on
DeclContext.
2025-01-27 19:25:41 -08:00