Commit Graph

2530 Commits

Author SHA1 Message Date
Xi Ge
06e63896cd ModuleInterface: consume _const keyword at var and parameter decls and keep them in textual/binary modules
This is to ensure users can start adding these annotations. Type checker supports will come in later commits.

Related to pitch: https://forums.swift.org/t/pitch-compile-time-constant-values/53606

rdar://85268028
2021-11-19 22:13:23 -08:00
Slava Pestov
28c1178c4f RequirementMachine: Introduce TypeAliasRequirementsRequest
This is a verbatim copy of the GenericSignatureBuilder's somewhat
questionable (but necessary for source compatibility) logic where
protocol typealiases with the same name as some other associated
type imply a same-type requirement.

The related diagnostics are there too, but only emitted when
-requirement-machine-protocol-signatures=on; in 'verify' mode,
the GSB will emit the same diagnostics.
2021-11-19 15:48:01 -05:00
Doug Gregor
71a980d93b Add @_predatesConcurrency attribute for declarations.
Introduce the `@_predatesConcurrency` attribute, which specifies that a
given declaration existed prior to the introduction of Swift
Concurrency, has been updated to use concurrency features (global
actors, Sendable, etc.), but should retain its pre-concurrency behavior
for clients that have not yet opted into concurrency.

Implement type and actor-isolation adjustments to
`@_predatesConcurrency` declarations to subsume the `@_unsafeMainActor`,
`@_unsafeSendable`, and `@MainActor(unsafe)` use cases. This is the
bulk of the semantic transformations needed for this new attribute,
but is not yet complete.

Part of rdar://84448438.
2021-11-16 21:39:31 -08:00
Konrad `ktoso` Malawski
a78d1bc47a Merge pull request #40179 from ktoso/wip-dist-func-protos
[Distributed] Improve error messages for protocol conformances
2021-11-16 15:07:35 +09:00
Konrad `ktoso` Malawski
f58b133a84 [Distributed] adjust conformance error messages a bit 2021-11-15 11:11:55 +09:00
Konrad `ktoso` Malawski
fcd93a5c1d [Distributed] Improve error messages for protocol conformances 2021-11-14 15:34:50 +09:00
Pavel Yaskevich
ad42a9fa21 [AST] Associated isActorSelf with VarDecl 2021-11-12 18:38:12 -08:00
Ellie Shin
e7577cea0e Updated comments and formatting 2021-11-10 15:34:02 -08:00
Ellie Shin
ea8b7a23b5 Fix case 2021-11-10 00:30:26 -08:00
Ellie Shin
9786a676a3 Fix param 2021-11-10 00:30:26 -08:00
Ellie Shin
e2631c9ca8 Move getRealImportPath to cpp
Remove unnecessary setter
Update tests
2021-11-10 00:30:26 -08:00
Ellie Shin
c08e7b9cd2 Module aliasing: modify ImportPath getters to return real module names
Resolves rdar://83632921, rdar://83633109
2021-11-10 00:30:25 -08:00
Robert Widmann
22405cefea Plumb the "Is Type Sequence" Bit Through the Surface AST 2021-11-08 13:48:30 -08:00
Anthony Latsis
a987ad619b Merge pull request #40082 from AnthonyLatsis/invalid-ext-bind
AST: Make sure malscoped extensions get their extended nominal computed
2021-11-08 20:52:20 +03:00
Anthony Latsis
5215fe5d95 AST: Make sure malscoped extensions get their extended nominal computed 2021-11-08 17:29:38 +03:00
Anthony Latsis
dd984b14f7 Merge pull request #35860 from AnthonyLatsis/enum-witness-no-accessor-req
Sema: Fix enum case witness crash when the requirement does not specify accessors
2021-11-03 07:50:41 +03:00
Anthony Latsis
fb8c6bd828 Sema: Correctly handle static 'let's in VarDecl::isSettable 2021-11-02 14:24:10 +03:00
Doug Gregor
d5175abeba Always weak-link symbols from the concurrency library when back-deploying
This allows applications that back-deploy but only use concurrency in
newer code to load and execute properly, even when the concurrency library
is not available. Fixes rdar://84877644.
2021-11-01 16:51:04 -07:00
Doug Gregor
913650dab1 Centralize Dispatch-related @_unsafe(Sendable|MainActor) hacks 2021-10-19 22:50:19 -07:00
Mishal Shah
c2fd49cebb Merge pull request #39473 from apple/rebranch
Update swift:main to support llvm-project:stable/20210726 changes (Rebranch merge)
2021-10-11 09:00:51 -07:00
Pavel Yaskevich
73f9392992 [AST] Allow pattern bindings to be marked as fully verified
This would be used by closures because they handle patterns
and initializers via solver and set them back to the pattern
binding decl as fully type-checked.
2021-10-08 10:08:03 -07:00
swift-ci
3f8fea8508 Merge remote-tracking branch 'origin/main' into rebranch 2021-10-06 10:17:29 -07:00
Doug Gregor
d04fff6f12 A @_distributedActorIndependent declaration is nonisolated.
The `@__distributedActorIndependent` attribute is effectively the same
as nonisolated, so start treating it that way by making actor-isolation
checking look for it specifically and conclude "nonisolated". Remove
various special cases for this attribute that don't need to exist.
2021-10-01 22:43:50 -07:00
swift-ci
c51550f30e Merge remote-tracking branch 'origin/main' into rebranch 2021-09-30 15:11:41 -07:00
Slava Pestov
1d427eaa12 AST: Add request to compute protocol structural requirements and dependencies
These will be used by the RequirementMachine to compute requirement
signatures. For now, they're not hooked up.

ProtocolDecl::getStructuralRequirements() produces a list of Requirements
with SourceLocs from the structural types written in the protocol's
inheritance clause and 'where' clauses.

ProtocolDecl::getProtocolDependencies() produces a list of protocols which
appear on the right hand side of the protocol's conformance requirements.
2021-09-28 14:31:32 -04:00
adrian-prantl
fcc77a67df Merge pull request #39032 from adrian-prantl/79462915-5.5
Disable resilience for modules imported by the MemoryBuffer loader.
2021-09-20 16:45:19 -07:00
Zoe Carver
f2f8bac056 Merge pull request #39134 from zoecarver/lazy-load-function-result-type
[cxx-interop] Lazily load the result of imported functions.
2021-09-09 11:44:21 -04:00
zoecarver
6e9bf50996 [cxx-interop] Lazily load the result of imported functions.
Note: we only lazily load the result if it's a record, because otherwise it's trivial to load when importing the function. Also, we still eagerly import operator's results types.
2021-09-08 17:48:39 -07:00
Hamish Knight
dc60996f89 Merge pull request #38836 from hamishknight/toil-and-tuple 2021-09-04 19:30:04 +01:00
Slava Pestov
4a019f0662 Sema: Improved recovery from circular generic signature construction
Returning a null GenericSignature is not the right way to break a cycle,
because then callers have to be careful to handle the case of a null
GenericSignature together with a non-null GenericParamList, for example
in applyGenericArguments().

An even worse problem can occur when a GenericSignatureRequest for a
nested generic declaration requests the signature of the parent context,
which hits a cycle. In this case, we would build a signature where
the first generic parameter did not have depth 0.

This makes the requirement machine upset, so this patch implements a new
strategy to break such cycles. Instead of returning a null
GenericSignature, we build a signature with the correct generic
parameters, but no requirements. The generic parameters can be computed
just by traversing GenericParamLists, which does not trigger more
GenericSignatureRequests, so this should be safe.
2021-09-04 00:13:03 -04:00
Konrad `ktoso` Malawski
b73050e49e Merge pull request #39095 from AnthonyLatsis/se-309
SE-0309: Unlock existential types for all protocols
2021-09-02 11:27:39 +09:00
Hamish Knight
01a082a058 [AST] Adopt ArgumentList
Switch out the representation of argument lists
in various AST nodes with ArgumentList.
2021-09-01 18:40:23 +01:00
Anthony Latsis
64b8f61b13 AST: Account for protocol compositions and nested types in «findProtocolSelfReferences» 2021-08-31 19:21:27 +03:00
Anthony Latsis
eb1bd07bb3 NFC: Remove the now dead ProtocolDecl::existentialTypeSupported() 2021-08-31 19:21:26 +03:00
Adrian Prantl
e754f5a6c4 Disable resilience for modules imported by the MemoryBuffer loader.
The MemoryBuffer loader is used by LLDB during debugging to import binary Swift
modules from .swift_ast sections. Modules imported from .swift_ast sections are
never produced from textual interfaces. By disabling resilience the expression
evaluator in the debugger can directly access private members.

rdar://79462915
2021-08-30 17:45:55 -07:00
Konrad `ktoso` Malawski
d76690ef58 [Distributed] improve getting _remote funcs; cache gets 2021-08-30 21:50:49 +09:00
Kavon Farvardin
c0607b345f Revert "Merge pull request #33767 from theblixguy/chore/remove-self-or-associated-type-diagnostic"
The following regression test added for this feature is not passing:

Swift(linux-x86_64) :: decl/protocol/protocols_with_self_or_assoc_reqs_executable.swift

with a compiler crash happening during SILFunctionTransform "Devirtualizer".

Reverting to unblock CI.

This reverts commit f96057e260, reversing
changes made to 3fc18f3603.
2021-08-26 16:46:42 -07:00
Konrad `ktoso` Malawski
f96057e260 Merge pull request #33767 from theblixguy/chore/remove-self-or-associated-type-diagnostic
SE-0309: Unlock existential types for all protocols
2021-08-27 06:09:47 +09:00
Konrad `ktoso` Malawski
beaf8a3203 Revert "[Distributed] Ensure _remote funcs synthesized before dynamic replacement (#38974)"
This reverts commit fe4ba18bf7.
2021-08-23 13:23:39 +09:00
Konrad `ktoso` Malawski
fe4ba18bf7 [Distributed] Ensure _remote funcs synthesized before dynamic replacement (#38974)
* [Distributed] Ensure _remote funcs synthesized before dynamic replacement

* cleanup

* remove redundant synthesis cause
2021-08-23 11:40:12 +09:00
Becca Royal-Gordon
c517b45bb4 Merge pull request #38948 from beccadax/the-copypasta-is-stale
[NFC] Factor out ASTContext `operator new`s
2021-08-20 11:04:56 -07:00
Becca Royal-Gordon
59bb325e4b [NFC] Factor out ASTContext operator news
Many, many, many types in the Swift compiler are intended to only be allocated in the ASTContext. We have previously implemented this by writing several `operator new` and `operator delete` implementations into these types. Factor those out into a new base class instead.
2021-08-19 11:19:52 -07:00
Anthony Latsis
655a81cbe6 AST: Account for protocol compositions and nested types in «findProtocolSelfReferences» 2021-08-16 18:30:26 +03:00
Anthony Latsis
755f0f96e0 NFC: Remove the now dead ProtocolDecl::existentialTypeSupported() 2021-08-16 18:30:26 +03:00
Konrad `ktoso` Malawski
bf37ba6014 [Distributed] Don't duplicate hasUserDefinedInit entry, less guards 2021-08-12 19:35:01 +09:00
Kavon Farvardin
89629fe06f Generalize BodyKind::MemberwiseInitializer
We'd like to support factor initializers
for distributed actor types that are
synthesized by SILGen.

We already do something similar for
memberwise initializers for structs.
Thus, this patch generalizes that
concept into a new BodyKind for
AbstractFunctionDecls called
BodyKind::SILSynthesize.

In addition, to help differentiate the
kinds of AFDs that are SILSynthesized
into different families for SILGen to
recognize, we also have a new enum
SILSynthesizeKind to indicate whether it
is a memberwise init, etc.
2021-08-12 14:05:31 +09:00
Kavon Farvardin
c9bfccb3b4 [distributed] a number of ctor infra cleanups
1. We're no longer synthesizing the local
init. All designated inits of a dist actor
must have exactly one ActorTransport parameter.
This parameter is used in the init's prologue
to initialize some of its members.

2. We're synthesizing a factory function for
the resolve initialization, instead of an
actor-member named `init` to serve that
purpose.

As such, much of the earlier infrastructure
is no longer needed, etc.
2021-08-12 14:04:51 +09:00
Konrad `ktoso` Malawski
1f33a0cc45 [Distributed] move where we invoke dist synthesis; detect transport param 2021-08-12 14:04:50 +09:00
Robert Widmann
d75b34be22 Merge pull request #38753 from CodaFi/modulo-modules
[NFC] Remove Unused Module Parameter to Conformance Lookup
2021-08-11 10:36:39 -07:00
Varun Gandhi
7bbc29a520 Merge pull request #38803 from varungandhi-apple/vg-objc-actors-took-2-weeks-of-my-life
[AST] Treat actors inheriting from NSObject as SwiftNativeNSObjects.
2021-08-09 10:54:01 -07:00