Commit Graph

1273 Commits

Author SHA1 Message Date
Slava Pestov
6549e0e168 AST: Introduce representation for pack conformances 2022-08-23 21:07:30 -04:00
Slava Pestov
3992b18e0b AST: Move some code from ASTPrinter.cpp to ASTDumper.cpp 2022-08-23 11:12:01 -04:00
Slava Pestov
ae37591c06 AST: Add a count type field to PackExpansionType
Even if we can't spell them in source, we want to model expansions where
the pattern does not depend on any pack type parameters, eg

    func f<C...: Collection>(_ c: C...) {
      let x = (c.count...)
    }

Here, the type of 'x' is notionally 'Int * C.count'.
2022-08-23 11:12:00 -04:00
Nate Chandler
b3ae13ddbe [Sema] Added _eagerMove and _lexical attributes.
The new attributes affect how the lifetimes of values may be shortened.
2022-08-21 21:44:53 -07:00
Michael Gottesman
c10c0f6285 [move-function] Add a new context sensitive move expr.
It doesn't do anything yet.
2022-08-08 12:50:41 -07:00
Pavel Yaskevich
3e65a7cab0 Merge pull request #60065 from xedin/result-builder-ast-transform-under-flag
[TypeChecker] Implement result builder transform via AST modification under a flag
2022-08-02 16:22:01 -07:00
Pavel Yaskevich
3167182871 [AST] Add TypeJoin expression
This expression represents a variable and a set of expressions
that are type-checked together to form a type of the variable.
2022-08-02 11:03:27 -07:00
Hamish Knight
9da53193da [AST] Remove ParameterTypeFlags from ParenType and TupleType
The last clients that relied on stashing parameter
type flags on these types are now gone.
2022-08-02 13:56:32 +01:00
Pavel Yaskevich
ceae9fdb5d Merge pull request #59854 from amritpan/improve-ast-printing
[ConstraintSystem] Improve ast printing in the type inference algorithm debug output
2022-07-04 00:41:07 -07:00
Michael Gottesman
198b974622 Merge pull request #59859 from gottesmm/pr-276c4e4220a25490659a285e8b94a36bd28ffede
[no-implicit-copy] Rename SILMoveOnlyType -> SILMoveOnlyWrappedType.
2022-07-01 23:17:43 -07:00
Amritpan Kaur
482db15e3a [ASTDumper] Consolidate series of closing parens into single line at end of AST in Initial Constraints and in the fully Type-checked expression. 2022-07-01 21:07:29 -07:00
Michael Gottesman
8f3fe63fed [no-implicit-copy] Rename SILMoveOnlyType -> SILMoveOnlyWrappedType.
Since I am beginning to prepare for adding real move only types to the language,
I am renaming everything that has to do with copyable types "move only wrapped"
values instead of move only. The hope is this reduces/prevents any confusion in
between the two.
2022-07-01 17:26:13 -07:00
Amritpan Kaur
6518791d6f [ASTDumper] Remove list of decl references in Initial Constraints to make AST easier to read. 2022-06-30 14:50:16 -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
fce3b856e3 [AST] Add new member access semantics - DistributedThunk
`DistributedThunk` is to be used while accessing 'distributed'
computed property outside of its actor context.
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
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
50a82e2868 [AST] Remove shouldApplyLookDistributedThunk flag from LookupExpr
The underlying mechanism has changed so the flag is no longer required.
2022-06-17 12:12:16 -07:00
Konrad `ktoso` Malawski
079bbcf517 wip 2022-06-17 12:12:16 -07:00
Michael Gottesman
c66061a783 [moveOnly] Add a new SIL specific AST type called SILMoveOnly.
It can only be used in SIL contexts to express that a wrapped type is
MoveOnly.
2022-06-03 11:27:16 -07:00
Pavel Yaskevich
644a720ce6 Merge pull request #59003 from xedin/rdar-92177656
[TypeChecker] Rework type-checking of `for-in` statements
2022-06-02 14:58:56 -07:00
Anthony Latsis
a9fb330a21 Fix a crash in the ASTDumper 2022-06-01 00:13:40 +03:00
Pavel Yaskevich
b7860ea055 [TypeChecker] Split for-in sequence into parsed and type-checked versions 2022-05-30 23:17:41 -07:00
Pavel Yaskevich
86165291aa [TypeChecker] Change the way for-in statement in type-checked
Instead of asking SILGen to build calls to `makeIterator` and
`$generator.next()`, let's synthesize and type-check them
together with the rest of for-in preamble. This greatly simplifies
interaction between Sema and SILGen for for-in statements.
2022-05-30 23:17:41 -07:00
Luciano Almeida
e8a8ecd92e [ASTDumper] Print async let for any_pattern that has an async let bit set e.g. let _: <type> = <expr> 2022-04-17 14:06:39 -03:00
Konrad `ktoso` Malawski
edd5880a59 [Distributed] SerializationReq must be associated type on DA 2022-04-13 21:52:15 +09:00
Alex Hoppen
0ded798ceb Merge pull request #42006 from ahoppen/pr/prepare-for-migrate-postfixexprparen
[CodeCompletion][Sema] Multiple improvements to prepare for migration of PostfixExprParen to solver-based
2022-04-03 16:43:36 +02:00
Anthony Latsis
4c2e88b207 Merge pull request #41849 from AnthonyLatsis/dyn_unbound_ref
CS: Handle unbound references to @objc optional methods
2022-03-31 04:01:20 +03:00
Pavel Yaskevich
a5a50a3658 [AST] NFC: Rename underlying type accessors of OpaqueTypeDecl
Adds a `Unique` component to the accessor names to draw the
distinction between unique and conditionally available substitutions.
2022-03-28 16:22:08 -07:00
Anthony Latsis
64ff2b22bb [NFC] ASTDumper: Tweak AppliedPropertyWrapperExpr dumping 2022-03-26 16:38:47 +03:00
Konrad `ktoso` Malawski
fa5321877e [Distributed] Remove unused request, small cleanup 2022-03-25 21:53:10 +09:00
Alex Hoppen
071090fd88 [AST] Don't crash when dumping a function type that doesn't have extInfo 2022-03-25 09:36:05 +01: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
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
Slava Pestov
7e5d6f4cb0 AST: Rework ParameterizedProtocolTypes to store multiple argument types
For now, this is NFC since we still assume one argument elsewhere.
2022-02-18 18:22:20 -05:00
Anthony Latsis
352b3a2f6d Merge pull request #41201 from AnthonyLatsis/opened-root
AST: Remove OpenedArchetypeType::getOpenedExistentialType()
2022-02-16 09:07:30 +03:00
Slava Pestov
a1c03db381 AST: Generalize ProtocolDecl::getRequirementSignature() to a new RequirementSignature type
The RequirementSignature generalizes the old ArrayRef<Requirement>
which stores the minimal requirements that a conforming type's
witnesses must satisfy, to also record the protocol typealiases
defined in the protocol.
2022-02-13 00:24:23 -05:00
Anthony Latsis
91bd2b1803 AST: Remove OpenedArchetypeType::getOpenedExistentialType()
Clients can explicitly ask for the opened existential type on the archetype's generic environment,
or use `getExistentialType` to obtain a specific archetype's upper bounds.
2022-02-04 16:22:50 +03:00
Slava Pestov
aa67c8bf8a Parametrized => parameterized 2022-02-03 13:27:24 -05:00
Slava Pestov
e7e536705e AST: Introduce ParametrizedProtocolType 2022-01-26 00:11:38 -05:00
Doug Gregor
452eccab83 Remove NestedArchetypeType.
Nested archetypes are represented by their base archetype kinds (primary,
opened, or opaque type) with an interface type that is a nested type,
as represented by a DependentMemberType. This provides a more uniform
representation of archetypes throughout the frontend.
2022-01-14 21:28:21 -08:00
Doug Gregor
b30c5b8334 Eliminate OpaqueTypeArchetypeType::getOrdinal(), which shouldn't be used
It only made sense on the root, and clients that care can look at the
interface type.
2022-01-14 21:26:29 -08:00
Doug Gregor
9b4d804142 Remove unnecessary uses of ArchetypeType::getParent().
The most interesting one of these is `ArchetypeType::getRoot()`, which
we reimplement in terms of getting the root generic parameter and then
looking up the archetype in the generic environment.
2022-01-14 21:25:31 -08:00
Doug Gregor
c5c1347594 Remove ArchetypeType::getKnownNestedTypes().
This API is only used for dumping and verification, and is not
intended to remain a meaningful query.
2022-01-14 21:25:31 -08:00
Zoe Carver
53ab3ef966 Merge pull request #34993 from zoecarver/cxx/cxxmethod-representation
[cxx-interop] Add SIL function representation cxx_method; Support extending C++ types.
2022-01-06 17:54:12 -08:00
zoecarver
036361d1e4 [cxx-interop] Add SIL function representation cxx_method; Support extending C++ types.
There are three major changes here:
    1. The addition of "SILFunctionTypeRepresentation::CXXMethod".
    2. C++ methods are imported with their members *last*. Then the arguments are switched when emitting the IR for an application of the function.
    3. Clang decls are now marked as foreign witnesses.

These are all steps towards being able to have C++ protocol conformance.
2022-01-06 14:26:47 -08:00
Doug Gregor
a5f676028b Eliminate remaining dependencies on a single underlying opaque type
The first generic parameter of an `OpaqueTypeDecl` was still being used
as the "underlying" interface type of the opaque type, which is
incorrect for both structural and named opaque result types. Eliminate
this notion, because the (declared) interface type already has the
correct structure.

Only ABI checking depended on the old "underlying" type, so rework it to
instead substitute into properly for structural opaque result types as
well.

Deserialization required a small adjustment to eliminate a cycle
because the interface type of an `OpaqueTypeDecl` involves opaque
archetype types, which reference the declaration itself... so
deserialize the interface type later, now that it's correct.
2022-01-04 11:55:42 -08:00
Doug Gregor
b60c88566f Fix serialization for structural opaque result types 2021-12-27 21:18:53 -08:00
Doug Gregor
9d22db44fc Profile and dump the ordinal of OpaqueTypeArchetypeType.
The "profile" of OpaqueTypeArchetypeType didn't contain the ordinal,
so multiple opaque types would collide.
2021-12-26 07:19:12 -08:00