Commit Graph

841 Commits

Author SHA1 Message Date
Slava Pestov
5b2211dde7 Serialization: Recover from failure to deserialize inheritance clause entries
... by dropping them.

Fixes <rdar://problem/50473619>.
2019-05-20 17:38:30 -04:00
Jordan Rose
96e8d56878 [Serialization] Add recovery for structs with non-loadable constraints
That is, if a struct's generic requirements can't be deserialized,
drop the struct. This is the same logic that's already in play for
enums and (as of the previous commit) classes, so it should be pretty
well tested by now. (Hence the sole test I'm adding here, snuck into
superclass.swift because it's a superclass /constraint/ being tested.)

I don't know of any outstanding issues caused by this, but it was
weird to have it for enums and classes but not structs, so here we
are.
2019-05-17 10:25:01 -07:00
Jordan Rose
ff7c6f6702 [Serialization] Drop a class if the superclass can't be found
...instead of crashing. Also drop the class if its generic
requirements depend on a type that can't be loaded (instead of
crashing).

rdar://problem/50125674
2019-05-17 10:25:01 -07:00
Jordan Rose
6cca050fd9 [Serialization] Retire "shadowed module" in favor of "underlying" (#24711)
Similar to 517f5d6b6a, the "shadowed" terminology didn't end up
describing the most common use of the feature; there is pretty much no
intended case where a Swift module shadows a Clang module without also
re-exporting it. Switch to "underlying", which was already in use in a
few places, and which better parallels "overlay".

No intended functionality change.
2019-05-13 10:20:03 -07:00
Doug Gregor
7092be6a28 [Property delegates] (De-)serialize property delegates attached to properties
Serialize the relationship between a property that has an attached delegate
and its backing variable, so deserialization can reestablish that link.

Fixes rdar://problem/50447022.
2019-05-05 21:44:54 -07:00
Slava Pestov
fa12d85739 AST: Clean up associated type default representation a bit 2019-04-26 21:47:02 -04:00
Nathan Hawes
1a2680a52f Merge pull request #24212 from nathawes/overriding-convenience-init-module-interface
[Deserialization] Don't add an OverrideAttr if the 'overridden' decl is a convenience init when deserializing
2019-04-24 13:58:16 -07:00
Nathan Hawes
2ae7315adf [Serialization] Don't add an OverrideAttr if the 'overridden' decl is a convenience init when deserializing 2019-04-22 18:08:03 -07:00
Doug Gregor
e29469b9c0 [Opaque result types] Fix mangling issues with opaque result types.
Fix a trio of issues involving mangling for opaque result types:
* Symbolic references to opaque type descriptors are not substitutions
* Mangle protocol extension contexts correctly
* Mangle generic arguments for opaque result types of generic functions

The (de-)serialization of generic parameter lists for opaque type
declarations is important for the last bullet, to ensure that the
mangling of generic arguments of opaque result types works across
module boundaries.

Fixes the rest of rdar://problem/50038754.
2019-04-22 17:10:45 -07:00
Joe Groff
5215290f25 Serialization: Cross-reference opaque return types by mangled name. rdar://problem/50005972 2019-04-18 14:41:26 -07:00
Joe Groff
b57f35220e Serialize opaque return type of var/subscript decls. 2019-04-17 14:46:22 -07:00
Joe Groff
f96ca720d3 Serialization: Handle reentrance while deserializing OpaqueTypeDecl. rdar://problem/49829836 2019-04-17 14:46:22 -07:00
Joe Groff
60aa49d69c merge fixup 2019-04-17 14:46:22 -07:00
Joe Groff
2d19110e38 Serialization: Serialize opaque types and their decls. 2019-04-17 14:43:32 -07:00
Slava Pestov
39a22f3d6a AST: Remove ParameterTypeFlags::Escaping
Escapingness is a property of the type of a value, not a property of a function
parameter. Having it as a separate parameter flag just meant one more piece of
state that could get out of sync and cause weird problems.

Instead, always look at the noescape bit in a function type as the canonical
source of truth.

This does mean that '@escaping' is now printed in a few diagnostics where it was
not printed before; we can investigate these as separate issues, but it is
correct to print it there because the function types in question are, in fact,
escaping.

Fixes <https://bugs.swift.org/browse/SR-10256>, <rdar://problem/49522774>.
2019-04-15 00:25:03 -04:00
Slava Pestov
8292cbe3b3 AST: Remove 'default argument resilience expansion'
This was a Swift 3 mode holdover.
2019-04-02 20:37:01 -04:00
Brent Royal-Gordon
972eda2316 [NFC] AST-level support for static subscripts
* Moves the IsStatic flag from VarDecl to AbstractStorageDecl.
* Adds a StaticSubscriptKind to SubscriptDecl.
* Updates serialization for these changes.
* Updates SubscriptDecl constructor call sites for these changes.
2019-04-01 18:04:00 -07:00
Doug Gregor
a848d12665 Parse unknown attributes as "custom" attributes.
Parse custom attributes with the grammar:

```
'@' type-identifier expr-paren?
```
2019-03-29 23:10:36 -07:00
Argyrios Kyrtzidis
dd40c70496 Merge pull request #23627 from akyrtzi/fix-bad-deserial-49336277
[Serialization] Fix bad tagging of deserialized decls that can result in failed member lookups
2019-03-28 15:36:42 -07:00
Argyrios Kyrtzidis
1b2cb9c723 [Serialization] Fix bad tagging of deserialized decls that can result in failed member lookups
The issue was introduced in ec95e68ab9 which changed the behavior of `ModuleFile::getDeclChecked()` slightly.

rdar://49336277
2019-03-28 12:18:25 -07:00
Ted Kremenek
fe215edb9b Merge pull request #19743 from Azoy/smarter-struct-init
[Sema] Synthesize default values for memberwise init
2019-03-25 17:31:01 -07:00
Jordan Rose
61d3b0d4ec [ClangImporter] Avoid unneeded copy for getExportedModuleName
std::string -> StringRef of long-lived backing storage.

No functionality change.
2019-03-21 15:16:21 -07:00
Jordan Rose
1bec714519 [Serialization] Recover when a typealias can't be deserialized (#23419)
We already detected when a typealias /changed/ incompatibly; being
unable to deserialize it at all is just a very dramatic version of
that, right?

https://bugs.swift.org/browse/SR-9811
2019-03-19 16:45:57 -07:00
Azoy
6f7d20b99e Synthesize default values for memberwise init
Introduce stored property default argument kind

Fix indent

Assign nil to optionals with no initializers

Don't emit generator for stored property default arg

Fix problem with rebase

Indentation

Serialize stored property default arg text

Fix some tests

Add missing constructor in test

Print stored property's initializer expression

cleanups

preserve switch

complete_constructor

formatting

fix conflict
2019-03-13 18:57:36 -05:00
Jordan Rose
4db46b07b6 [Serialization] Make the input/output of a helper lambda clearer
It still has side effects, and it's still a lambda rather than a
helper function because it's not used anywhere else, but `[&]`
captures in helper lambdas make me nervous (as opposed to callback
lambdas).
2019-02-22 09:01:42 -08:00
Jordan Rose
fff69c9df6 [Serialization] Unify ExistentialMetatype and Metatype deserialization 2019-02-22 09:01:42 -08:00
Jordan Rose
da9fa9eb64 [Serialization] Move the rest of the type layouts into TypeDeserializer 2019-02-22 09:01:40 -08:00
Jordan Rose
0297d8fc3d [Serialization] Move one type's deserialization into a method
...to prove it can be done.
2019-02-22 08:59:36 -08:00
Jordan Rose
cdadaad9b5 [Serialization] Push caching of deserialized types out of helper class
Decls need to do this to avoid re-entrancy issues, but it turns out
types are simpler. I left a dummy "result" variable in the minimize
churn, since I'm going to move all the cases into their own functions
anyway.
2019-02-22 08:59:36 -08:00
Jordan Rose
23fdccc373 [Serialization] Start getTypeChecked() -> TypeDeserializer
Like I just did for DeclDeserializer. This one adds the new class and
moves most of getTypeChecked() into it, but doesn't yet split anything
up.
2019-02-22 08:59:33 -08:00
Joe Groff
64488b19f9 Serialization: Rework serialization of nested archetypes.
Explicitly serialize the parent archetype so that it can be any kind of root archetype.
2019-02-20 12:53:18 -08:00
Jordan Rose
b577838fa9 [Serialization] Collapse prefix/postfix operator deserialization
...using a template.
2019-02-13 20:23:39 -08:00
Jordan Rose
ec95e68ab9 [Serialization] Collapse one level of helper function I didn't need
No functionality change.
2019-02-13 20:23:39 -08:00
Jordan Rose
855ad2ca87 [Serialization] Move all the decl layouts into DeclDeserializer
Now we have a separate function for each serialized declaration kind!
Much cleaner, still NFC.
2019-02-13 20:23:39 -08:00
Jordan Rose
83586c74f0 [Serialization] Move helper lambda into DeclDeserializer
And cache the ASTContext pointer for convenience.
2019-02-13 20:23:39 -08:00
Jordan Rose
9f80d71bfb [Serialization] Move various RAII-based setup into DeclDeserializer
No functionality change.
2019-02-13 20:23:39 -08:00
Jordan Rose
8c062232c5 [Serialization] Make ASTDeserializer stateful, and use that state
...for decl attributes. Also, rename to DeclDeserializer.
2019-02-13 20:23:39 -08:00
Jordan Rose
e5408748cd [Serialization] Move one case in getDeclCheckedImpl out of line
...as a proof of concept. The next commit will move them /all/ out of
line.

(The intent here is to produce better backtraces when not recovering
from errors.)
2019-02-13 20:23:39 -08:00
Jordan Rose
b5a86cf3af [Serialization] Move decl attribute deserialization into new helper
No functionality change.
2019-02-13 20:23:39 -08:00
Jordan Rose
3273f06879 [Serialization] Pull decl deserialization out to a helper class
In preparation for splitting up one big switch into many small
methods. Well, medium-sized methods.

No functionality change.
2019-02-13 20:23:38 -08:00
Jordan Rose
106c470a10 [Serialization] Handle re-export of error enums harder (#21880)
A refinement of Doug's e3207f753c from a year ago to account for
trying to reference an import-as-member error enum /through/ an
overlay when it's in a Clang module using 'export_as'. The problem is
that importing error enums synthesizes a corresponding struct, and
that struct doesn't have a Clang node and so when it isn't found in
the right module the compiler didn't know to allow it anyway.

I know, right?

(Looking at the source change might be simpler than trying to read
the above paragraph.)

I'm still not 100% sure on how this occurred in the original
(Apple-internal) projects hitting this, but I think it's just that we
handle all import-as-member types at once, and the clients were using
something else from a type that contained the error enum, and then
that resulted in the error struct's conformances getting written into
a serialized swiftmodule.

rdar://problem/47152185
2019-01-15 15:02:19 -08:00
Parker Schuh
f5859ff46e Rename NameAliasType to TypeAliasType. 2019-01-09 16:47:13 -08:00
Ankit Aggarwal
45290837b4 Merge pull request #21110 from aciidb0mb3r/swiftpm-manifest-version
Extend @available to support PackageDescription
2019-01-07 12:20:23 -08:00
Joe Groff
89979137fc Push ArchetypeType's API down to subclasses.
And clean up code that conditionally works only with certain kinds of archetype along the way.
2018-12-12 19:45:40 -08:00
Jordan Rose
4017416d5e [Serialization] Only allow loading modules during import resolution (#21218)
Very early groundwork for private imports. Should not affect anything
today.
2018-12-12 10:50:20 -08:00
Slava Pestov
544e0a02d5 AST: Don't link together GenericParamLists of nested generic types
GenericParamList::OuterParameters would mirror the nesting structure
of generic DeclContexts. This resulted in redundant code and caused
unnecessary complications for extensions and protocols, whose
GenericParamLists are constructed after parse time.

Instead, lets only use OuterParameters to link together the multiple
parameter lists of a single extension, or parameter lists in SIL
functions.
2018-12-11 23:55:41 -05:00
Slava Pestov
e0c1e819c8 Serialization: Redo generic param xrefs to use GenericSignature
This code used GenericParamList::getOuterParameters() and
DeclContext::getGenericParamsOfContext(). The meaning of the
former is about to change, and the latter is going away.
2018-12-11 23:22:18 -05:00
Ankit Aggarwal
92d09f4e19 Extend @available to support PackageDescription
<rdar://problem/46548531> Extend @available to support PackageDescription

This introduces a new private availability kind "_PackageDescription" to
allow availability testing by an arbitary version that can be passed
using a new command-line flag "-swiftpm-manifest-version". The semantics
are exactly same as Swift version specific availability. In longer term,
it maybe possible to remove this enhancement once there is
a language-level availability support for 3rd party libraries.

Motivation:

Swift packages are configured using a Package.swift manifest file. The
manifest file uses a library called PackageDescription, which contains
various settings that can be configured for a package. The new additions
in the PackageDescription APIs are gated behind a "tools version" that
every manifest must declare. This means, packages don't automatically
get access to the new APIs. They need to update their declared tools
version in order to use the new API. This is basically similar to the
minimum deployment target version we have for our OSes.

This gating is important for allowing packages to maintain backwards
compatibility. SwiftPM currently checks for API usages at runtime in
order to implement this gating. This works reasonably well but can lead
to a poor experience with features like code-completion and module
interface generation in IDEs and editors (that use sourcekit-lsp) as
SwiftPM has no control over these features.
2018-12-08 09:38:40 +05:30
Harlan Haskins
245109d909 Merge pull request #20250 from harlanhaskins/accessorizing
[ParseableInterface] Standardize printing for accessors
2018-11-27 10:31:17 -08:00
Harlan Haskins
a20c31abf1 [Serialization] Add @_hasStorage and private(set) while deserializing 2018-11-26 18:42:02 -08:00