Commit Graph

2390 Commits

Author SHA1 Message Date
Holly Borla
37c0964d3e [Sema] Rename existentialTypeSupported to existentialRequiresAny, and
flip the return value in the implementation accordingly.
2021-12-09 23:15:02 -08:00
Holly Borla
00a4629515 Revert "NFC: Remove the now dead ProtocolDecl::existentialTypeSupported()"
This reverts commit eb1bd07bb3.
2021-12-09 23:15:02 -08:00
zoecarver
fc3b3a1d71 [cxx-interop] Implement foreign reference types.
This is an expiremental feature to allow an attribute, `import_as_ref`, to import a C++ record as a non-reference-counted reference type in Swift.
2021-12-08 15:35:18 +00:00
Saleem Abdulrasool
349af3707d Merge pull request #40305 from compnerd/semitruck
gardening: make c++98-compat-extra-semi an error
2021-11-30 08:18:36 -08:00
Ben Barham
e78abc2b80 Merge pull request #40319 from bnbarham/loc-leaks
[AST] Prevent memory leak when allocating `ExternalSourceLocs`
2021-11-30 19:58:07 +10:00
Ben Barham
50a73a3965 [AST] Prevent memory leak when allocating ExternalSourceLocs
c763ab5d1e fixed an issue in
`getSerializedLocs` where it never actually cached its result (and thus
always allocated a new `CachedExternalSourceLocs`). Unfortunately it
missed a leak that could occur when `DocRanges` grows beyond its initial
size of 4.

Allocate `DocRanges` upfront in the `ASTContext` as well in order to
prevent this leak.

Resolves rdar://85472403.
2021-11-30 10:31:31 +10:00
Doug Gregor
0c9c8f92c9 Imported C declarations always predate concurrency 2021-11-29 15:03:33 -08:00
Slava Pestov
7be6058088 Merge pull request #40268 from slavapestov/rqm-inferred-generic-signature-request
RequirementMachine: Implement InferredGenericSignatureRequest
2021-11-29 17:50:33 -05:00
Saleem Abdulrasool
910fbee14e gardening: make c++98-compat-extra-semi an error
This cleans up 90 instances of this warning and reduces the build spew
when building on Linux.  This helps identify actual issues when
building which can get lost in the stream of warning messages.  It also
helps restore the ability to build the compiler with gcc.
2021-11-27 11:40:17 -08:00
Xi Ge
7856bbae53 sema: require witness for _const decls to be also _const 2021-11-22 15:18:29 -08:00
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