Commit Graph

3502 Commits

Author SHA1 Message Date
Doug Gregor
b60c88566f Fix serialization for structural opaque result types 2021-12-27 21:18:53 -08:00
Doug Gregor
99a9c021e2 Carry through the ordinal for opaque type declarations.
Generalize the implementation of opaque type declarations to maintain
the "ordinal", which represents a particular "some" utterance in a
structural opaque type, throughout more of the compiler.

The ordinal value for a given "some" matches with the index of the
corresponding generic parameter in the opaque type declaration's
generic signature. To properly be able to determine the ordinal for a
given "some" type representation, retain all of the "some" type
representations in the `OpaqueTypeDecl` (using trailing storage), so
we can map them to the proper generic parameter and ordinal later on.
2021-12-24 22:06:48 -08:00
Rintaro Ishizaki
473ecd8c80 Merge pull request #40645 from rintaro/sourcekit-compilerserver
[SourceKit] Add a request to generate object files in SourceKit
2021-12-21 22:29:11 -08:00
Kavon Farvardin
386940ce6d some vars need unspecified isolation for initializing exprs
It's possible to create an impossible set of constraints for
instance-member stored properties of a type. For example:

@MainActor func getStatus() -> Int { /* ... */ }
@PIDActor func genPID() -> ProcessID { /* ... */ }

class Process {
  @MainActor var status: Int = getStatus()
  @PIDActor var pid: ProcessID = genPID()

  init() {} // Problem: what is the isolation of this init?
}

We cannot satisfy the isolation of the initilizing expressions,
which demand that genStatus and genPID are run with isolation
from a non-async designated initializer, which is not possible.

This patch changes the isolation for those initializer expressions
for instance members, saying that the isolation is unspecified.

fixes rdar://84225474
2021-12-21 17:52:28 -08:00
Rintaro Ishizaki
7c92a8e555 [SourceKit] Add a request to generate object files in SourceKit
Add 'request.compile'
2021-12-21 14:35:38 -08:00
Robert Widmann
e5bfda7c6e Merge pull request #40587 from CodaFi/substitute-teacher
Initial Semantics for Variadic Generics
2021-12-20 11:25:25 -08:00
swift-ci
3e98dd4dc0 Merge pull request #40619 from DougGregor/swiftfoundation-nsobject 2021-12-17 15:55:26 -08:00
Doug Gregor
fd413664ae Allow SwiftFoundation to declare NSObject, too
Fixes rdar://86495060.
2021-12-17 13:17:32 -08:00
Robert Widmann
d4b8f1df96 Implement TypeBase::isTypeSequenceParameter
Behaves much like isTypeParameter but specifically checks for the type sequence bits. Also, add the type sequence bits as a recursive type property.
2021-12-16 01:16:45 -08:00
Konrad `ktoso` Malawski
cee89ec541 [Distributed] DistributedActorSystem renaming and redesign (#40387)
* [Distributed] towards DistributedActorSystem; synthesize the id earlier, since Identifiable.id

* Fix execute signature to what Pavel is working with

* funcs are ok in sil

* fixed lifetime of id in inits

* fix distributed_actor_deinit

* distributed_actor_local

* update more tests

fixing tests

fix TBD test

fix Serialization/distributed

fix irgen test

Fix null pointer crashes

* prevent issues with null func ptrs and fix Distributed prorotocol test

* fix deinit sil test
2021-12-13 11:29:25 +09:00
Doug Gregor
b92f0b6167 Merge pull request #40513 from DougGregor/actor-isolated-local-function 2021-12-10 21:03:38 -08:00
Doug Gregor
3f5ee47db8 Consistently handle 'self' captures 2021-12-10 16:21:02 -08:00
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