Commit Graph

87 Commits

Author SHA1 Message Date
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
Konrad `ktoso` Malawski
8159b239d1 [Distributed] Handle dispach thunks of decodeNextArgument in Distributed IRGen
correct way to detect dispatch thunk presence in GenDistributed
2023-10-20 10:30:46 +09:00
Doug Gregor
ef642098f2 [Typed throws] Parsing and AST representation for typed errors
Parse typed throw specifiers as `throws(X)` in every place where there
are effects specified, and record the resulting thrown error type in
the AST except the type system. This includes:
* `FunctionTypeRepr`, for the parsed representation of types
* `AbstractFunctionDecl`, for various function-like declarations
* `ClosureExpr`, for closures
* `ArrowExpr`, for parsing of types within expression context

This also introduces some serialization logic for the thrown error
type of function-like declarations, along with an API to extract the
thrown interface type from one of those declarations, although right
now it will either be `Error` or empty.
2023-09-29 10:51:51 -07:00
Slava Pestov
7f9a71cd15 AST: Rename ASTContext::getConformance() to getNormalConformance() 2023-08-09 17:42:25 -04:00
Allan Shortlidge
0e9b8a1e0a Sema: Relax distributed actor typechecking for swiftinterfaces.
Some decls that are expected to be synthesized for distributed actors are
printed explicitly in swiftinterfaces so diagnostics and assertions need to
take that possibility into account.

Resolves rdar://108533918
2023-04-26 08:44:44 -07:00
Hamish Knight
d56f4633c3 [Sema] Ensure synthesized NamedPatterns have types 2023-04-06 16:11:11 +01:00
Doug Gregor
0cb2746c49 Keep track of source files created for macro expansions and such.
Introduce a new source file kind to describe source files for macro
expansions, and include the macro expression that they expand. This
establishes a "parent" relationship

Also track every kind of auxiliary source file---whether for macro
expansions or other reasons---that is introduced into a module, adding
an operation that allows us to find the source file that contains a
given source location.
2022-11-01 08:03:26 -07:00
Konrad `ktoso` Malawski
728c007fb9 [Distributed] Implement witnesses for sync or non-throw dist reqs
[Distributed] generic and inner test; without one edge case

[Distributed] fix distributed_thunk test; unsure about those extra hops, could remove later

[Distributed] Remove type pretending in getSILFunctionType; it is not needed

It seems our constant replacement in the earlier phases is enough, and
we don't need this trick at all.

[Distributed] Use thunk when calling cross-actor on DA protocols
2022-07-04 19:02:11 +09:00
Konrad `ktoso` Malawski
ef525424f6 Merge pull request #59700 from xedin/distributed-computed-properties-via-accessor-thunk
[Distributed] Implement distributed computed properties via special accessor
2022-06-30 16:04:36 +09:00
Pavel Yaskevich
2480c99dee [Distributed] Generate thunk for accessor as a regular method
It used to be an accessor but that is not required because
SILDeclRef controls mangling which is the most imprortant
and could be used to emit the right reference.
2022-06-29 17:57:58 -07:00
Pavel Yaskevich
8d9962e605 [Distributed] Allow requesting distributed thunks on AbstractStorageDecl
One step towards future distributed subscripts.
2022-06-29 14:49:10 -07:00
Pavel Yaskevich
84fa2322d3 [Distributed] Synthesize 'distributed thunk' accessor for distributed computed properties 2022-06-29 14:49:10 -07:00
Pavel Yaskevich
b2b1efd268 [Distributed] Decl: Add a new distributed-thunk bit
The flag is used to distinguish between regular functions/accessors
and synthesized distributed thunks.
2022-06-29 14:49:10 -07:00
Pavel Yaskevich
a016fae223 [TypeChecker] Distributed: Verify properties before attempting to synthesize a thunk 2022-06-29 14:49:10 -07:00
Pavel Yaskevich
d68961d407 [Distributed] Synthesize thunks for distributed computed properties 2022-06-29 14:49:10 -07:00
Pavel Yaskevich
c0479a5b0c [Distributed] NFC: remove a couple of unused variables from sythensis code 2022-06-29 14:49:10 -07:00
Pavel Yaskevich
5bdf94f346 [Distributed] Remove commented out code and print statements 2022-06-29 14:49:10 -07:00
Konrad `ktoso` Malawski
febfef97d4 [Distributed] Skeleton implementation of distributed computed properties 2022-06-29 14:49:04 -07:00
Konrad `ktoso` Malawski
fa077c1390 [Distributed] distributed func checks now work in protocols & dont crash 2022-06-27 17:17:45 +09:00
Konrad `ktoso` Malawski
22b20afce6 [Distributed] make witness be the distributed thunk 2022-06-27 17:08:55 +09:00
Konrad `ktoso` Malawski
6a2778645f Revert "Merge pull request #59481 from xedin/distributed-computed-properties"
This reverts commit 8125a85a8f, reversing
changes made to 728971c5b7.
2022-06-25 08:49:00 +09:00
Pavel Yaskevich
fa2e64c1fd [Distributed] Sema: Add a new distributed-thunk attribute
The attribute comes handy during solution application to
determine whether the call is using a distributed thunk.
2022-06-17 12:35:54 -07:00
Pavel Yaskevich
2078aa95d4 [Distributed] NFC: remove a couple of unused variables from sythensis code 2022-06-17 12:35:54 -07:00
Pavel Yaskevich
ce641063e0 [TypeChecker] Distributed: Verify properties before attempting to synthesize a thunk 2022-06-17 12:12:16 -07:00
Pavel Yaskevich
b963c6d20f [Distributed] Remove commented out code and print statements 2022-06-17 12:12:16 -07:00
Pavel Yaskevich
435aa65fbe [Distributed] Synthesize thunks for distributed computed properties 2022-06-17 12:12:16 -07:00
Konrad `ktoso` Malawski
5a5b7c007c towards distributed getters 2022-06-17 12:12:16 -07:00
Doug Gregor
74503f00ff Use the distributed thunk for non-distributed protocol requirements (#59513)
When a distributed-actor-isolated witness is provided for a
non-distributed-actor-isolated requirement, always hop to the
distributed thunk.

While here, mark distributed thunks as being `final`, to ensure that
we always statically call them vs. trying to retrieve them from the
vtable (since they aren't in the vtable).
2022-06-17 11:13:59 +09:00
Konrad `ktoso` Malawski
df462ea320 [Distributed] Be able to synthesize actorSystem prop from request (#59460)
* [Distributed] Be able to synthesize actorSystem prop from request

* [Distributed] remove duped lookupProp func, we have it in swift::

* Undo removal of method which was duped on 5.7 but is not on main
2022-06-16 09:53:37 +09:00
Konrad `ktoso` Malawski
1e489d6c0b [Distributed] Force the order of properties in AST 2022-05-08 18:20:50 +09:00
Konrad `ktoso` Malawski
e01bcc470f [Distributed] SILGen must consistently use prop get requests 2022-04-23 07:49:54 +09:00
Konrad `ktoso` Malawski
317fdd0740 [Distributed] Guard ID synthesis from synthesizing the property multiple times; e.g. during multi module builds 2022-04-22 23:18:16 +09:00
Konrad `ktoso` Malawski
7e176db932 [Distributed] Cache checking distributed func 2022-04-12 06:32:13 +09:00
Konrad `ktoso` Malawski
7332e4b3eb [Distributed] avoid double typechecking dist func decl 2022-03-29 09:02:43 +09:00
Konrad `ktoso` Malawski
fa5321877e [Distributed] Remove unused request, small cleanup 2022-03-25 21:53:10 +09:00
Konrad `ktoso` Malawski
ef10cd016a [Distributed] Fix generic returning distributed funcs 2022-03-25 16:19:08 +09:00
Kavon Farvardin
af683dc271 basic implementation of performing an init of the id after an assign of the actorSystem.
The resignID call within the initializer moved into DI, because an assignment to
the actorSystem, and thus initialization of the id, is no longer guaranteed to happen.
Thus, while we previously could model the resignation as a clean-up emitted on all
unwind paths in an initializer, now it's conditional, based on whether the id was
initialized. This is exactly what DI is designed to do, so we inject the resignation
call just before we call the identity's deinit.
2022-03-24 16:20:01 -07:00
Konrad `ktoso` Malawski
8d3e7d91c0 [Distributed] ResultHandler.onReturn must be ad-hoc because SerializationRequirement (#41916)
* [Distributed] Invoke handler.onReturn ad hoc via ast synthesized func

* reformat and cleanup

* remove unused var
2022-03-24 21:44:37 +09:00
Konrad `ktoso` Malawski
14fb9a03ff Merge pull request #41871 from xedin/fix-mark-protocol-issues-related-to-distributd
[Distributed] Strip marker protocols from distributed thunks and accessible functions
2022-03-18 21:08:04 +09:00
Pavel Yaskevich
c9a0295d6d [Distributed] Synthesis: Start using special mangling for distributed thunks 2022-03-17 14:02:42 -07:00
Konrad `ktoso` Malawski
5a5d1ba2e6 [Distributed] Implement RemoteCallArgument 2022-03-17 22:55:09 +09:00
Konrad `ktoso` Malawski
ea29723466 [Distributed] Add name parameter to recordArgument for better interop 2022-03-17 20:05:31 +09:00
Robert Widmann
b183ae13fa Merge pull request #41812 from CodaFi/imap
Stabilize VarDecl::isLet for ParamDecls
2022-03-15 15:51:14 -07:00
Konrad `ktoso` Malawski
14bbd27e83 [Distributed] remove a few warnings 2022-03-15 17:13:41 +09:00
Robert Widmann
539a5b3338 [NFC] Remove Redundant Calls to VarDecl::setIntroducer 2022-03-14 18:12:11 -07:00
Konrad `ktoso` Malawski
6d502fc042 [Distributed] Implicit Codable conformance for Dist Actors
[Witness] implement dump() on witness
2022-03-11 18:07:14 +09:00
Konrad `ktoso` Malawski
5ab8e0834d [Distributed] Reimplement distributed call thunks completely in AST (#41616)
* [Distributed] dist actor always has default executor (currently)

* [Distributed] extra test for missing makeEncoder

* [DistributedDecl] Add DistributedActorSystem to known SDK types

* [DistributedActor] ok progress on getting the system via witness

* [Distributed] allow hop-to `let any: any X` where X is DistActor

* [Distributed] AST: Add an accessor to determine whether type is distributed actor

- Classes have specialized method on their declarations
- Archetypes and existentials check their conformances for
  presence of `DistributedActor` protocol.

* [Distributed] AST: Account for distributed members declared in class extensions

`getConcreteReplacementForProtocolActorSystemType` should use `getSelfClassDecl`
otherwise it wouldn't be able to find actor if the member is declared in an extension.

* [Distributed] fix ad-hoc requirement checks for 'mutating'

[PreChecker] LookupDC might be null, so account for that

* [Distributed] Completed AST synthesis for dist thunk

* [Distributed][ASTDumper] print pretty distributed in right color in AST dumps

* wip on making the local/remote calls

* using the _local to mark the localCall as known local

* [Distributed] fix passing Never when not throwing

* fix lifetime of mangled string

* [Distributed] Implement recordGenericSubstitution

* [Distributed] Dont add .

* [Distributed] dont emit thunk when func broken

* [Distributed] fix tests; cleanups

* [Distributed] cleanup, move is... funcs to DistributedDecl

* [Distributed] Remove SILGen for distributed thunks, it is in Sema now!

* [Distributed]  no need to check stored props in protocols

* remote not used flag

* fix mangling test

* [Distributed] Synthesis: Don't re-use AST nodes for `decodeArgument` references

* [Distributed] Synthesis: Make sure that each thunk parameter has an internal name

* [Distributed/Synthesis] NFC: Add a comment regarding empty internal parameter names

* [Distributed] NFC: Adjust distributed thunk manglings in the accessor section test-cases

* cleanup

* [Distributed] NFC: Adjust distributed thunk manglings in the accessor thunk test-cases

* review follow ups

* xfail some linux tests for now so we can land the AST thunk

* Update distributed_actor_remote_functions.swift

Co-authored-by: Pavel Yaskevich <xedin@apache.org>
2022-03-10 23:58:23 +09:00
Konrad `ktoso` Malawski
005743c92c [Distributed] implement adhoc requirements properly for Encoder 2022-02-14 16:14:41 +09:00
Konrad `ktoso` Malawski
c7e3af84e4 [Distributed] Handle composite types in SerializationRequirement 2022-02-11 19:26:18 +09:00
Konrad `ktoso` Malawski
12932c7b3c [Distributed] Introduce DistributedDecl.h for greater reuse 2022-02-11 19:25:57 +09:00