Commit Graph

136 Commits

Author SHA1 Message Date
Slava Pestov
819738c83e AST: Rename mapTypeIntoContext() => mapTypeIntoEnvironment(), mapTypeOutOfContext() => mapTypeOutOfEnvironment() 2025-11-12 14:48:19 -05:00
Hamish Knight
d3278360be [Sema] NFC: Add a couple of comments 2025-11-04 13:54:34 +00:00
Hamish Knight
0f58eb2104 [Sema] Fix and cleanup distributed id/actorSystem synthesis (#85245) 2025-11-04 10:17:05 +09:00
Hamish Knight
73710e3eef [AST] Introduce Decl::addAttribute
Introduce a convenience entrypoint that also calls `attachToDecl` on
the attribute, and migrate all existing uses of `getAttrs().add` onto
it.
2025-10-16 11:21:54 +01:00
Konrad Malawski
ced1756142 [Concurrency/Distributed] ensure distributed thunks are @concurrent
Otherwise the "nonisolated nonsending by default" mode blows up as
distributed thunk signatures dont match expectations.

This undoes the fix from https://github.com/swiftlang/swift/pull/83940
and applies the fix on the synthesis side of the distributed thunks,
such that they are @concurrent always -- which keeps their old semantics
basically, regardless of what "default" mode we have.
2025-09-03 18:54:09 +09:00
Konrad Malawski
c1491c8022 [Concurrency/Distributed] nonisolated-nonsending by default breaks distributed thunks
the new NonisolatedNonsendingByDefault upcoming feature breaks remote
calls in distributed actors, because the expected isolation doesn't
match and the runtime swift_distributed_execute_target_resume will
crash.

This is a short term fix to unblock adopters, however preferably we
should mark the thunks as nonisolated(nonsending), though that seems to
be more involved.

resolves rdar://159247975
2025-08-28 21:53:41 +09:00
Anthony Latsis
fec049e5e4 Address llvm::PointerUnion::{is,get} deprecations
These were deprecated in
https://github.com/llvm/llvm-project/pull/122623.
2025-07-29 18:37:48 +01:00
Anthony Latsis
ad8c52237c Sema: Fix the insertion location for conformances attributes 2025-06-24 14:49:03 +01:00
Slava Pestov
cf1572c65b AST: Add ASTContext::TheSelfType for convenience 2025-04-28 11:49:50 -04:00
Pavel Yaskevich
3906980f58 [AST] NFC: Add a convenient way to create implicit NonisolatedAttrs 2025-04-11 15:59:25 -07:00
Anthony Latsis
3fd8f0a008 [NFC] Sema: Factor out derived conformance sources into subdirectory 2025-04-05 05:32:37 +01:00
Allan Shortlidge
8819d6db9e Distributed: Squash a -Wparentheses warning.
The following warning was being  emitted by newer versions of clang:

```
comparisons like 'X<=Y<=Z' don't have their mathematical meaning [-Wparentheses]
```

This code needs to be reworked to ensure that the conditions that are meant to
be asserted are true.
2025-04-01 16:47:56 -07:00
Anthony Latsis
a84dfc8387 [Gardening] Fix some set but not used variables 2025-01-30 21:34:38 +00:00
Allan Shortlidge
d0f63a0753 AST: Split Availability.h into multiple headers.
Put AvailabilityRange into its own header with very few dependencies so that it
can be included freely in other headers that need to use it as a complete type.

NFC.
2025-01-03 18:36:04 -08:00
Doug Gregor
5b90b8851a Generalize protocol conformance options spelled via attribute and incorporate @unsafe
Protocol conformances have a handful attributes that can apply to them
directly, including @unchecked (for Sendable), @preconcurrency, and
@retroactive. Generalize this into an option set that we carry around,
so it's a bit easier to add them, as well as reworking the
serialization logic to deal with an arbitrary number of such options.

Use this generality to add support for @unsafe conformances, which are
needed when unsafe witnesses are used to conform to safe requirements.
Implement general support for @unsafe conformances, including
producing a single diagnostic per missing @unsafe that provides a
Fix-It and collects together all of the unsafe witnesses as notes.
2024-12-20 23:16:23 -08:00
Kuba Mracek
6f4ae28520 [ASTMangler] Pass ASTContext to all instantiations of ASTMangler 2024-12-02 15:01:04 -08:00
Alejandro Alonso
f4f60f4344 Remove Value requirement Add GenericTypeParamKind 2024-09-04 15:13:43 -07:00
Alejandro Alonso
75c2cbf593 Implement value generics
Some requirement machine work

Rename requirement to Value

Rename more things to Value

Fix integer checking for requirement

some docs and parser changes

Minor fixes
2024-09-04 15:13:25 -07:00
Slava Pestov
375363a473 AST: Move global conformance lookup entry points to ConformanceLookup.h 2024-08-08 23:35:58 -04:00
Hamish Knight
18531b6bd3 [Sema] Enforce PatternTypeRequest returns contextual type
A bunch of synthesis code was getting this wrong
and setting an interface type for a TypedPattern.
Assert that we have a contextual type, and update
some synthesis logic.
2024-07-06 23:18:17 +01:00
Slava Pestov
86d567f95a AST: ModuleDecl::lookupConformance() is a static method 2024-07-06 12:05:47 -04:00
Slava Pestov
3fcda140bb AST: ModuleDecl::checkConformance() is a static method 2024-07-06 12:05:46 -04:00
Tim Kientzle
1098054291 Merge branch 'main' into tbkka-assertions2 2024-06-18 17:52:00 -07:00
Konrad `ktoso` Malawski
4bae14a5c4 [Distributed] Improve erroring out when distributed types not found
also return early when type hasError
2024-06-12 13:57:31 +09:00
Konrad `ktoso` Malawski
e650dc00df [Distributed] Distributed thunks take parameters as 'sending'
This is in order to avoid errors in complete concurrency checking mnode
in distributed funcs, or rather their thunks, as there is isolation
boundary crossing happening when we pass a value to a distributed func.

This is because as we do this, we pass it to a nonisolated thunk:

```
nonisolated func THUNK(param: Thing) {
  if remote {
    ...
  } else {
    await self.realFunc(param)
  }
}
```

So what happens here is that the Thing would become isolated to the
task and we get a bad isolation crossing as we pass it along to the
"real func".

Sending values into the distributed thunk is the right thing to do to
resolve this problem: `nonisolated func THUNK(param: sending Thing) {}`

Resolves rdar://126577527
2024-06-06 12:32:47 +09:00
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Konrad `ktoso` Malawski
168bc7b454 [Concurrency] Fix how we obtain DA-as-A conformance for cross module
Resolves rdar://127206143
2024-05-28 13:37:21 +09:00
Konrad `ktoso` Malawski
7cd9063ba5 [Distributed] Diagnose missing import also for funcs in extensions
Resolves rdar://125813581
2024-04-09 17:08:27 +09:00
Konrad `ktoso` Malawski
6132386371 [Distributed] Complete handling of protocol calls and witnesses using adjusted mangling scheme (#72416) 2024-03-23 23:54:23 +09:00
Konrad `ktoso` Malawski
8854438d87 [Distributed] Remove _distributedThunkTarget; it is not necessary (#72245) 2024-03-11 20:48:05 -07:00
Konrad `ktoso` Malawski
143d8f9801 [Distributed] Handle distributed thunk requirements/witnesses (#72151)
Co-authored-by: Pavel Yaskevich <pyaskevich@apple.com>
2024-03-11 02:07:22 -07:00
Konrad `ktoso` Malawski
b7ff16baf7 [Distributed] Only synthesize Codable for DA where the ID is Codable (#72081) 2024-03-07 22:40:00 -08:00
Pavel Yaskevich
7b7716cda9 [AST/Sema] Distributed: Introduced unified way to retrieve serialization requirements for actors 2024-03-06 13:51:14 -08:00
Slava Pestov
53193f11e9 Sema: Fix compiler warning 2024-02-29 18:13:28 -05:00
Konrad `ktoso` Malawski
c56a1e8be7 [Distributed] Handle mangling thunks in extensions with generic AS and $Stubs (#71914) 2024-02-29 04:22:00 -08:00
Konrad `ktoso` Malawski
1d44e2e8e0 [Distributed] Undo new record and mangling scheme for dist.p.witnesses (#71801) 2024-02-22 23:02:29 +09:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Konrad `ktoso` Malawski
e9c7f3c382 [Distributed] Target identifiers for protocol calls (#70928) 2024-02-16 07:19:20 -08:00
Doug Gregor
81ffafdc6a Merge pull request #70602 from ApolloZhu/macro/expression-as-default-argument
[Macros] Expression macro as caller-side default argument
2024-02-14 16:10:11 -08:00
Pavel Yaskevich
e85bd1f07d [Sema] Distributed: Adjust distributed thunk synthesis to use witnesses for actorSystem references
Things like `makeInvocationEncoder()` and all of the `record*`
methods can now be called through witnesses.
2024-02-12 14:26:30 -08:00
Konrad `ktoso` Malawski
1d73afb296 [Distributed] Handle DA declared inside a generic type (#71492) 2024-02-08 21:32:34 -08:00
Apollo Zhu
b09a22a9a0 Somewhat working
Test shadowed variable of same type

Fully type check caller side macro expansion

Skip macro default arg caller side expr at decl primary

Test macro expand more complex expressions

Set synthesized expression as implicit

Add test case for with argument, not compiling currently

Test with swiftinterface

Always use the string representation of the default argument

Now works across module boundary

Check works for multiple files

Make default argument expression work in single file

Use expected-error

Disallow expression macro as default argument

Using as a sub expression in default argument still allowed as expression macros behave the same as built-in magic literals
2024-02-06 15:02:11 -08:00
Slava Pestov
af50d7e6b8 AST: Add allowInverses flag to AbstractGenericSignatureRequest 2024-02-05 18:43:06 -05:00
Hamish Knight
c97d80b1c3 [AST] NFC: Add convenience constructors for ReturnStmt
Add `ReturnStmt::createParsed` and `createImplict`.
2024-01-23 19:30:18 +00:00
Pavel Yaskevich
6cdab78028 Merge pull request #70867 from xedin/dynamic-enforcement-of-witness-isolation-with-preconcurrency
[TypeChecker/SILGen] Dynamic enforcement of witness/objc isolation with @preconcurrency attribute
2024-01-17 10:01:37 -08:00
Slava Pestov
14d1fcb51a AST: TypeChecker::conformsToProtocol() => ModuleDecl::checkConformance() 2024-01-16 17:08:00 -05:00
Pavel Yaskevich
e8b7a26eac [AST] Add a flag to indicate that the conformance is @preconcurrency 2024-01-16 11:51:42 -08:00
Konrad `ktoso` Malawski
30653a8091 [Distributed] Don't crash in thunk generation when missing SR conformance 2023-11-14 20:57:33 +09:00
Sophia Poirier
4c9a726183 nonisolated(unsafe) to opt out of strict concurrency static checking for global variables 2023-10-26 16:22:28 -07:00
Doug Gregor
5ad39c84e0 [Typed throws] Record thrown error types and conversions in the AST
For any operation that can throw an error, such as calls, property
accesses, and non-exhaustive do..catch statements, record the thrown
error type along with the conversion from that thrown error to the
error type expected in context, as appropriate. This will prevent
later stages from having to re-compute the conversion sequences.
2023-10-24 12:40:22 -07:00