Commit Graph

2410 Commits

Author SHA1 Message Date
Anthony Latsis
89667f8783 CSApply: Refactor 'buildCurryThunk' to use 'buildSingleCurryThunk' 2022-03-26 18:28:24 +03:00
Anthony Latsis
5a9010819d CSApply: Replace some 'buildPropertyWrapperFnThunk' calls with the new 'buildSingleCurryThunk' 2022-03-26 18:28:24 +03:00
Anthony Latsis
969324d9b6 [NFC] CSApply: Introduce generalized and convenience routines for building single curry thunks 2022-03-26 18:28:24 +03:00
Anthony Latsis
f25725279e [NFC] CSApply: Introduce a generalized routine for building single curry thunk bodies 2022-03-26 18:28:20 +03:00
Pavel Yaskevich
be08bac7e7 [CSApply] Use declaration context associated with rewriter
`ExprRewriter` could be created for a solution application target,
which could have its own declaration context if it's e.g. an inner
statement or a pattern binding.
2022-03-23 15:18:35 -07:00
Pavel Yaskevich
c6de8088c6 Merge pull request #41960 from xedin/csgen-casts-without-reprs
[CSGen/CSApply] Don't expect implicit casts to have type reprs
2022-03-23 12:26:19 -07:00
Pavel Yaskevich
15772e4a72 [CSApply] Ajust expression rewriter to handle casts without reprs
Implicit casts are allowed to provide cast type directly without
a type repr, adjust solution application logic to handle this just
like constraint generator does. Also fix a couple of places where
declaration context from constraint system was used instead
of one associated with the expression rewriter.
2022-03-23 00:18:55 -07:00
Alex Hoppen
e2a62f1a60 [CodeCompletion] Migrate expression completions to solver-based 2022-03-21 13:00:33 +01:00
Robert Widmann
363954a416 Put Variadic Generics Behind a Flag 2022-03-16 14:22:03 -07:00
Pavel Yaskevich
894c932ad0 [CSApply] Use decl context of target when applying solution to it
Solution application target can have its declaration context differ
from one used for constraint system, since target could be e.g. a
pattern associated with pattern binding declaration, a statement or
a sub-element of one (e.g. where clause) used in a closure etc.
2022-03-14 10:09:35 -07: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
Robert Widmann
4efcb825f5 Unlock Opaque Types in Parameterized Protocols
Represent this in much the same way that collections do by creating an opaque value representing the source argument, and a conversion expression representing the destination argument.
2022-03-08 23:45:37 -08:00
Robert Widmann
ab44a07045 Convert DeclContext Parameters to their Associated Generic Signatures Instead 2022-03-07 22:54:23 -08:00
Robert Widmann
d6186c9cfb Add a DeclContext Parameter to Opened Archetype Construction
This ensures that opened archetypes always inherit any outer generic parameters from the context in which they reside. This matters because class bounds may bind generic parameters from these outer contexts, and without the outer context you can wind up with ill-formed generic environments like

<τ_0_0, where τ_0_0 : C<T>, τ_0_0 : P>

Where T is otherwise unbound because there is no entry for it among the generic parameters of the environment's associated generic signature.
2022-03-07 22:54:22 -08:00
Zoe Carver
d3c40ef9f1 Merge pull request #41624 from zoecarver/cache-thunks-for-spec
[cxx-interop] Cache specialized function templates.
2022-03-03 14:15:44 -08:00
Pavel Yaskevich
26d85520a2 Merge pull request #41589 from xedin/handle-expr-patterns-in-the-solver
[ConstraintSystem] Support solving expression patterns via injecting call to `~=` operator
2022-03-02 16:33:52 -08:00
zoecarver
680d5d2cc8 [nfc] [cxx-interop] Move function template specialization logic into clang-module-loader. 2022-03-02 10:58:14 -08:00
swift-ci
ad903094c0 Merge pull request #41386 from beccadax/your-library-is-overdue
Weaken some type checks for @preconcurrency decls
2022-03-01 16:13:59 -08:00
Pavel Yaskevich
59154d6d71 [ConstraintSystem] Support solving expression patterns via injecting call to ~= operator
Augment the constraint solver to fallback to implicit `~=` application
when member couldn't be found for `EnumElement` patterns because
`case` statement should be able to match enum member directly, as well
as through an implicit `~=` operator application.
2022-02-28 17:02:28 -08:00
Pavel Yaskevich
50d0508a4b [ConstraintSystem] Add a new contextual type purpose - expression pattern
This makes it possible to associate expression with its parent pattern.
2022-02-25 12:30:22 -08:00
Zoe Carver
5974cd0908 Merge pull request #41466 from zoecarver/support-basic-inout-case 2022-02-18 22:03:25 -08:00
Doug Gregor
e3af684772 Merge pull request #41183 from DougGregor/implicitly-open-existentials 2022-02-18 18:04:04 -08:00
zoecarver
f73e20b795 [cxx-interop] Fix crash when inout parameter is used in some "template contexts".
We used to incorrectly forward inout paramters in the thunk for both template paramters that aren't used in the signature and in the thunk for dependent types as Any.

Now this works in the simple case. We'll need to do something more complicated when we have an `inout Any` for dependent types because we will need to somehow cast without copying. This will probably require synthesising the SIL of the thunk manually.
2022-02-18 15:11:14 -08:00
Becca Royal-Gordon
c2ccb874ab Soften actor isolation in closures passed to @preconcurrency
When a closure is not properly actor-isolated, but we know that we inferred its isolation from a `@preconcurrency` declaration, we now emit the errors as warnings in Swift 5 mode to avoid breaking source compatibility if the isolation was added retroactively.
2022-02-18 14:29:16 -08:00
Doug Gregor
e30c8a5c09 Allow opening existentials for inout parameters. 2022-02-18 11:22:57 -08:00
Doug Gregor
1e1b3427c3 Experimental support for implicitly opening existential arguments.
When calling a generic function with an argument of existential type,
implicitly "open" the existential type into a concrete archetype, which
can then be bound to the generic type. This extends the implicit
opening that is performed when accessing a member of an existential
type from the "self" parameter to all parameters. For example:

    func unsafeFirst<C: Collection>(_ c: C) -> C.Element { c.first! }

    func g(c: any Collection) {
      unsafeFirst(c)   // currently an error
                       // with this change, succeeds and produces an 'Any'
    }

This avoids many common sources of errors of the form

    protocol 'P' as a type cannot conform to the protocol itself

which come from calling generic functions with an existential, and
allows another way "out" if one has an existention and needs to treat
it generically.

This feature is behind a frontend flag
`-enable-experimental-opened-existential-types`.
2022-02-18 11:22:56 -08:00
Zoe Carver
4a67288168 Merge pull request #41440 from zoecarver/members-with-dependent-types
[cxx-interop] Fix calling methods with dependent types.
2022-02-18 11:06:16 -08:00
zoecarver
47064a0eda [cxx-interop] Fix calling methods with dependent types.
Both instance members and static methods.
2022-02-18 09:21:55 -08:00
zoecarver
970489b72f [cxx-interop] [nfc] Don't emit a cast if the cast is a no-op. 2022-02-18 09:19:43 -08:00
zoecarver
0d60c2e25d Revert "Revert "[cxx-interop] Start to import dependent types as Any""
This reverts commit fdb417a2e5.
2022-02-17 13:23:14 -08:00
Saleem Abdulrasool
fdb417a2e5 Revert "[cxx-interop] Start to import dependent types as Any" 2022-02-16 20:20:36 -08:00
zoecarver
9ff5bb1f45 [cxx-interop] Add support for dependent types as Any.
Dependent types are going to be very hard to support, especially in complex cases. This PR adds a workaround that people can use: `Any`. This requires manual type casting, but it does work.
2022-02-16 12:44:14 -08:00
zoecarver
02a621962c [nfc] Re-factor logic in resolveConcreteDeclRef into separate static functions. 2022-02-16 12:43:48 -08:00
Zoe Carver
b60dcc1d24 Merge pull request #41394 from zoecarver/revert-revert-cleanup-and-fixes-for-function-templates 2022-02-16 08:30:16 -08:00
Anthony Latsis
352b3a2f6d Merge pull request #41201 from AnthonyLatsis/opened-root
AST: Remove OpenedArchetypeType::getOpenedExistentialType()
2022-02-16 09:07:30 +03:00
zoecarver
83e3f9657d [nfc] Re-factor logic in resolveConcreteDeclRef into separate static functions. 2022-02-15 20:09:15 -08:00
zoecarver
a1f9aae63f [cxx-interop] Fix integer substitution on watchOS.
Basically watchOS had the same issue as Windows.
2022-02-15 16:51:14 -08:00
zoecarver
283fc782ec Revert "Revert "[cxx-interop] A few cleanups and fixes for function templates.""
This reverts commit 5de09631ff.
2022-02-15 13:30:10 -08:00
Zoe Carver
5de09631ff Revert "[cxx-interop] A few cleanups and fixes for function templates." 2022-02-13 09:54:39 -08:00
Zoe Carver
0e7af7a7cd Merge pull request #41217 from zoecarver/cleanup-and-fixes-for-function-templates 2022-02-12 14:10:41 -08:00
zoecarver
83e465f763 Move up the Windows hack and fix it for static members/inits. 2022-02-11 20:51:11 -08:00
zoecarver
4cb1704b0e [nfc] Clang format the PR. 2022-02-11 13:57:31 -08:00
zoecarver
6da5e7ee06 [cxx-interop] Fix (U)Int substituted params on Windows.
Re-write the parameter list to use (U)Int if that was one of the substituted parameters. This is required because Windows will incorrectly map Int -> long long -> Int64.
2022-02-11 13:57:04 -08:00
Hamish Knight
aa6942e462 [CS] Simplify visitCoerceExpr slightly
Remove the unused `choice` parameter.
2022-02-10 19:06:47 +00:00
Pavel Yaskevich
f1e602f98d Merge pull request #41189 from xedin/trailing-closures-with-callAsFunction
[ConstraintSystem] Match trailing closures to implicit `.callAsFunction` when necessary
2022-02-08 17:44:55 -08:00
zoecarver
daceecfc75 [cxx-interop] Remove generateSpecializedCXXFunctionTemplate and just import the decl directly.
1) This unifies two code paths that do essentially the same thing.
2) This fixes how we import certain types (such as return types).
2022-02-04 16:18:02 -08: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
Pavel Yaskevich
36c02e4291 [CSApply] Implement support for implicit .callAsFunction after init with trailing closures
Situations like `T(...) { ... }` where `T` is a callable type
and trailing closure belongs to `.callAsFunction` should be
rewritten as `T.init().callAsFunction { ... }`.
2022-02-03 15:36:18 -08:00
Slava Pestov
aa67c8bf8a Parametrized => parameterized 2022-02-03 13:27:24 -05:00
Anthony Latsis
c7fd60f2dd Merge pull request #39492 from AnthonyLatsis/se-309-2
SE-309: Covariant erasure for dependent member types
2022-02-02 07:07:17 +03:00