Commit Graph

3502 Commits

Author SHA1 Message Date
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
Rintaro Ishizaki
accd108e4a Merge pull request #79857 from rintaro/retire-pound-diagnostics-decl
[Parse/AST] Remove PoundDiagnosticDecl
2025-03-09 21:23:16 -07:00
Rintaro Ishizaki
002d7d7cdf [Parse/AST] Remove PoundDiagnosticDecl
There is no reson to make a AST node for '#error' and '#warning'
directives. Parser knows the diagnostics should be emitted or not.
2025-03-07 21:48:01 -08:00
Nate Chandler
35d06c325d [CoroutineAccessors] Witness and vtable dispatch.
And thunking.
2025-03-07 11:46:50 -08:00
nate-chandler
38c8cc8ff4 Merge pull request #77661 from nate-chandler/general-coro/20241115/1
[CoroutineAccessors] Default implementations are transparent.
2025-03-07 11:39:21 -08:00
Allan Shortlidge
b64df7384e AST: Simplify AvailabilityRange construction.
Introduce a constructor that takes an `llvm::VersionTuple` directly, instead of
needing to spell out `VersionRange::allGTE(<tuple>)` which is unnecessarily
verbose.
2025-03-04 19:41:04 -08:00
Artem Chikin
de26e960e2 Rename '_const' attribute to 'CompileTimeLiteral'
To pave the way for the new experimental feature which will operate on '@const' attribute and expand the scope of what's currently handled by '_const' without breaking compatibility, for now.
2025-03-04 07:30:02 -08:00
Allan Shortlidge
c89df2fc38 AST/Sema: Adopt AvailabilityDomain arguments in more diagnostics.
Update explicit unavailability and deprecation diagnostics to take
`AvailabiiltyDomain` instead of a platform string.
2025-02-28 13:57:00 -08:00
Doug Gregor
52c46f838a Parsing and type checking for the definition of isolated conformances
Allow a conformance to be "isolated", meaning that it stays in the same
isolation domain as the conforming type. Only allow this for
global-actor-isolated types.

When a conformance is isolated, a nonisolated requirement can be
witnessed by a declaration with the same global actor isolation as the
enclosing type.
2025-02-25 21:16:51 -08:00
Pavel Yaskevich
b84bf055f0 [TypeChecker] Implement ExtensibleEnums feature exhaustivily handling
If an enum comes from a different module that has `ExtensibleEnums`
feature enabled, unless it requires either `@unknown default:` or
`@frozen` because it is allowed to introduce new cases in the future
versions of the module.
2025-02-25 00:05:23 -08:00
Kuba (Brecka) Mracek
874c62513c Merge pull request #79403 from kubamracek/embedded-unique-macro-names
[Macros] Recognize the $e Embedded Swift prefix in MacroDecl::isUniqueMacroName
2025-02-24 10:16:40 -08:00
stzn
43e60304ad Add sending to subscript getter sending result 2025-02-23 10:52:01 +09:00
Rintaro Ishizaki
efea164d04 [ASTGen] Generate from 'MissingTypeSyntax'
Just emit ErrorTypeRepr
2025-02-21 11:36:29 -08:00
Rintaro Ishizaki
6805e155d5 Merge pull request #79503 from rintaro/astgen-paramdecl-typerepr
[AST] Sink ParamDecl flag collection logic from Parse to AST
2025-02-21 02:18:52 -08:00
fahadnayyar
9782eae585 Merge pull request #77522 from fahadnayyar/cxx-frt-inheritance-diagnostics
[cxx-interop] Infer SWIFT_SHARED_REFERENCE for types inheriting from a C++ foreign reference type
2025-02-20 13:46:28 -08:00
Rintaro Ishizaki
8833ff58a2 [AST] Sink the flag collection logic from Parse to AST
* Collect flag in `ParamDecl::setTypeRepr()`.

* [ASTGen] Separate `BridgedParamDecl.setTypeRepr(_:)` from
`BridgedParamDecl.createParsed(_:)` aligning with C++ API. The majority
of the creations don't set the typerepr.

* Update `ParamSpecifierRequest::evaluate` to handle non-implicit
`ParamDecl` without `TypeRepr` (i.e. untyped closure parameter), instead
of `setSpecifier(::Default)` manually in Parse.
2025-02-20 10:04:49 -08:00
fahadnayyar
d8f919778d [cxx-interop] [cxx-interop] Infer SWIFT_SHARED_REFERENCE for types inheriting from a C++ foreign reference type
rdar://97914474
2025-02-20 08:46:57 -08:00
Rintaro Ishizaki
e5d5026992 Merge pull request #79456 from rintaro/astgen-paramdecl
[ASTGen] ParamDecl generation improvements
2025-02-19 14:05:55 -08:00
Allan Shortlidge
342dc1d36f AST: Fix an unused variable warning in Decl.cpp. 2025-02-18 21:31:48 -08:00
Rintaro Ishizaki
6980509f8c [ASTGen] Generate DefaultArgumentInitializer
Rework ParamDecl contextualization.
2025-02-18 11:13:39 -08:00
Gabor Horvath
410341671e [SE-0458] Unify escapibility inference for AST and Interop
Interop is injecting escapability annotations for the STL and doing a
limited inference for aggregates. Let's reuse the same facilities in the
AST when we calculate the safety of the foreign types.
2025-02-17 13:41:40 +00:00
Doug Gregor
c2e36decfe Merge pull request #79424 from DougGregor/se-0458-match-proposal
[SE-0458] Bring implementation in line with the latest proposal revision
2025-02-16 19:15:27 -08:00
Allan Shortlidge
902053341e Merge pull request #79423 from tshortli/case-iterable-invalid-available
AST: Type-check `@available` attributes before synthesizing `CaseIterable`
2025-02-16 17:58:10 -08:00
Allan Shortlidge
b6ee0796c8 AST: Type-check @available attributes before synthesizing CaseIterable.
An `AvailableAttr` written in source with an unrecognized availability domain
is now only marked invalid after type-checking the attribute. This resulted in a
regression where `CaseIterable` synthesis was blocked incorrectly under the
following very narrow circumstances:

1. Every `@available` attribute on the elements of the enum is invalid.
2. The module is being emitted and lazy type-checking is enabled.
3. The enum is public and the only top-level declaration in the file.

Type-checking the attribute was delayed just enough that it would not be
considered invalid by the type the `CaseIterable` conformance was being
synthesized, resulting in a spurious error.

There were zero tests exercising `CaseIterable` synthesis for enums with
elements that have availability requirements, so I added some.

Resolves rdar://144897917.
2025-02-16 12:20:48 -08:00
Hamish Knight
1e8dc55b7f [AST] NFC: Remove InitRetType
This is no longer used.
2025-02-16 18:52:23 +00:00
Doug Gregor
c0fb9f990a [Strict memory safety] Infer safe/unsafe for imported C types 2025-02-16 00:55:43 -08:00
Kuba Mracek
e037aaaf85 [Macros] Recognize the $e Embedded Swift prefix in MacroDecl::isUniqueMacroName 2025-02-14 14:23:26 -08:00
Anthony Latsis
e8b393430f Merge pull request #78459 from AnthonyLatsis/tuber-magnatum-2
TypeCheckType: Unconditionally warn about missing existential `any` until Swift 7
2025-02-14 19:08:33 +00:00
Rintaro Ishizaki
e066bb266b Merge pull request #79355 from rintaro/astgen-toplevelvardecl
[ASTGen] Generate PatternBindingDecl at top level
2025-02-13 09:43:10 -08:00
Rintaro Ishizaki
6ea6a31ec7 [ASTGen] Generate TopLevelCodeDecl for PatternBindingDecl
* Instead of hoisting VarDecl in the bridging functions, do it in
  ASTGen.
* Introduce `Decl::forEachDeclToHoist` to handle VarDecls in
  PatternBindingDecl, and EnumElementDecl in EnumCaseDecl.
* Intorduce `withBridgedSwiftClosure(closure:call:)` as a callback
  mechanism between Swift and C++
* In `generate(sourceFile:)`, instead of using `generate(codeBlockItem:)`
  handle `CodeBlockItemSyntax.Item` manually to handle `TLCD` wrapping
  and `VarDecl` hoisting.
* Make `generate(variableDecl:)` handle TLCD correctly.
2025-02-13 00:09:22 -08:00
Rintaro Ishizaki
563ddc47e2 [AST] Eliminate 'SYNTAX_KIND' from MagicIdentifierKinds.def
Nothing is using it.
2025-02-12 23:19:34 -08:00
Anthony Latsis
fe2408c0ab TypeCheckType: Unconditionally warn about missing existential any until Swift 7
https://github.com/swiftlang/swift/pull/72659 turned out to have some
source compatibility fallout that we need to fix. Instead of introducing
yet another brittle compatibility hack, stop emitting errors about a
missing `any` altogether until a future language mode.

Besides resolving the compatibility issue, this will encourage
developers to adopt any sooner and grant us ample time to gracefully
address any remaining bugs before the source compatibility burden
resurfaces.

A subsequent commit adds a diagnostic group that will allow users to
escalate these warnings to errors with `-Werror ExistentialAny`.
2025-02-12 21:20:44 +00:00
Slava Pestov
17d8c820dc Merge pull request #79220 from slavapestov/fix-rdar143950572
AST: Source range of FuncDecl/ConstructorDecl should include the thrown type
2025-02-10 13:49:37 -05:00
Slava Pestov
a6a96da558 AST: Source range of FuncDecl/ConstructorDecl should include the thrown type
When a function declaration has a body, its source range ends at the
closing curly brace, so it includes the `throws(E)`. However, a
protocol requirement doesn't have a body, and due to an oversight,
getSourceRange() was never updated to include the extra tokens
that appear after `throws` when the function declares a thrown
error type. As a result, unqualified lookup would fail to find a
generic parameter type, if that happened to be the thrown type.

Fixes rdar://problem/143950572.
2025-02-10 09:17:40 -05:00
Michael Gottesman
8c5b49e65a Merge pull request #79204 from gottesmm/undo-concurrent-for-now
[concurrency] For now undo ActorIsolation::Concurrent refactoring.
2025-02-06 23:06:15 -08:00
Michael Gottesman
7e350bb4ce Revert "[concurrency] Add Concurrent/ConcurrentUnsafe and use it instead of ActorIsolation::Nonisolated."
This reverts commit 0cb64638d0.
2025-02-06 14:05:06 -08:00
Michael Gottesman
f05f08c2c0 Revert "[concurrency] Make ActorIsolation::Nonisolated -> CallerIsolationInheriting and delete CallerIsolationInheriting."
This reverts commit 543b1e6ca3.
2025-02-06 14:04:30 -08:00
elsh
ee751835fc Package CMO: Skip deserialization error checks for same-module decls.
IterableDeclContext::checkDeserializeMemberErrorInPackage recursively checks if
decls and their member decls are deserialized correctly into another module.
This PR adds a check to make sure the inspected decls are from another module,
and provides an opt-in flag to fail fast on deserialization failure if found.

rdar://143830240
2025-02-05 14:27:00 -08:00
Michael Gottesman
342bbd309e Merge pull request #79087 from gottesmm/actor-isolation-refactoring
[concurrency] Introduce concurrent, swap its meaning with nonisolated and make nonisolated caller inheriting isolation.
2025-02-03 17:48:38 -08:00
Pavel Yaskevich
82e5d7fd90 Merge pull request #79042 from stzn/fix-subscipt-sending
[Sema]Set IsSending flag to subscript.getter if needed
2025-02-03 16:13:22 -08:00
Michael Gottesman
543b1e6ca3 [concurrency] Make ActorIsolation::Nonisolated -> CallerIsolationInheriting and delete CallerIsolationInheriting. 2025-02-03 10:56:08 -08:00
Michael Gottesman
0cb64638d0 [concurrency] Add Concurrent/ConcurrentUnsafe and use it instead of ActorIsolation::Nonisolated.
This is just the first part of a larger transition.
2025-02-03 10:56:06 -08:00
stzn
65ac75fae5 [Sema]Set IsSending flag to subscript.getter if needed 2025-02-01 06:43:15 +09: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
Anthony Latsis
a84dfc8387 [Gardening] Fix some set but not used variables 2025-01-30 21:34:38 +00:00
QuietMisdreavus
ab26b8b9d7 add support to getTopLevelDecls for clang submodules (#76401)
rdar://126031510
2025-01-30 09:39:58 -07:00
Ellie Shin
997eab4410 Merge pull request #79019 from swiftlang/elsh/downgrade-to-warning
Package CMO: downgrade error to warning when checking for deserialization errors.
2025-01-29 23:30:17 -08: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
elsh
4b6e0bf8d9 Package CMO: downgrade error to warning when checking for deserialization errors.
Binary module built with Package CMO can be loaded for package-external client
modules which do not have direct access to decls that are serialized_for_package.
Downgrade build-time error to warning when a deserialization error is found for
a decl that should be allowed to access by package-external clients resiliently.

rdar://143800032
2025-01-29 10:46:02 -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