Commit Graph

1046 Commits

Author SHA1 Message Date
Arnold Schwaighofer
1719f0cdf1 Serialization: Also serialize the filename for internal storage decls with private accessors
If a value decl is internal hasTestableOrPrivateImport will succeed (or
fail) without looking at the filename. However this breaks when we query
an internal storage decl with private formal access for a private
setter: the query would fail because no filename was serialized for the
decl (we only serialize filenames for private decls). So in the special
case of a internal storage with private accessor also serialize the
filename.

rdar://48516545
2019-03-04 13:12:39 -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
Joe Groff
0cfca9496a Give opened archetypes a generic environment.
And maybe allow nested types to live on them.
2019-02-20 12:52:48 -08:00
Doug Gregor
d31ef61a28 Eliminate "sorting" of DeclContext-local protocols / conformances.
Sorting of DeclContext-local protocols and conformances shouldn't ever
be necessary, because the underlying data structures that produce
these lists should be deterministic. Sorting can hide any
non-determinism, so stop doing it and we can address the underlying
nondeterminism.
2019-02-15 14:16:48 -08:00
Jordan Rose
2301bff548 Add some defensive checks against invalid serialization (#22466)
If a non-serializable Decl or Type makes it into serialization logic
in a release build, an invalid swiftmodule might be produced silently,
leading to crashes in clients. Try to catch this with an on-in-Release
check that /something/ was serialized. (This is my best guess at how
rdar://problem/47459323 occurred.)
2019-02-08 09:04:08 -08:00
Harlan Haskins
6f94720b01 [Serialization] Use mtime instead of hash for file dependencies
Hashing the contents of the interface files is overkill. In practice, size and last modification time are enough to determine if a file has changed on disk, and therefore should be rebuilt.
2019-02-04 13:26:38 -08:00
Slava Pestov
2b90ad1b4a ASTMangler: Don't optimize protocol names in debugger mangling 2019-01-30 01:28:48 -05:00
Robert Widmann
c5b7230d22 [NFC] Upgrade EnumElementDecl to a DeclContext
Pure plumbing for the sake of default arguments.
2019-01-16 18:39:30 -05: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
Harlan Haskins
11f4d05db4 [Serialization] Only serialize inlinable body text in partial modules
Since this text is only needed for printing a parseable interface during
a non-whole-module build, only put the text inside partial modules. When
we're merging the modules at the end, skip serializing the text.

rdar://44394186
2018-12-13 14:29:34 -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
Joe Groff
f1648a1b3e Split subclasses out of ArchetypeType.
Context archetypes and opened existential archetypes differ in a number of details, and this simplifies the overlapping storage of the kind-specific fields. This should be NFC; for now, this doesn't change the interface of ArchetypeType, but should allow some refinements of how the special handling of certain archetypes are handled.
2018-12-12 08:55:56 -08: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
Jordan Rose
1f25ea51d7 Fix two issues with typealiases in protocol extensions (#20654)
- The GenericSignatureBuilder assumed it didn't have to look in
  protocol extensions to resolve member types.

- Serialization was incorrectly filtering out such typealiases when
  trying to resolve a cross-module reference to one.

rdar://problem/46103190
2018-11-26 11:31:12 -08:00
John McCall
1065f99c71 Assorted fixes for the self-conformance infrastructure 2018-11-15 22:41:58 -05:00
John McCall
5553224fd4 Support the explicit representation of self-conformances.
Big, but actually NFC because we're never actually creating them.
2018-11-15 16:42:03 -05:00
Graydon Hoare
b07425ac1d [ModuleInterface] Switch from mtime to xxhash in FILE_DEPENDENCY records. 2018-11-13 13:25:15 -08:00
Pavel Yaskevich
bce1ba5f37 [AST] Remove @autoclosure flag from function type ExtInfo 2018-11-10 11:59:29 -08:00
Pavel Yaskevich
0857611fa0 [Serialization] Add @autoclosure to parameter decl serialization format 2018-11-10 11:59:28 -08:00
Slava Pestov
c7338d06ca AST: Remove owning addressors 2018-11-09 20:49:44 -05:00
Arnold Schwaighofer
3fe6d363e1 Address more feedback to the private import change 2018-11-09 16:11:30 -08:00
Jordan Rose
4539dbfd06 [Serialization] Simplify the representation of GenericParamLists (#20446)
Now that we don't store requirements in the GenericParamList, there's
no reason to use trailing records to list out the
GenericTypeParamDecls.

No functionality change.
2018-11-09 14:17:30 -08:00
Arnold Schwaighofer
f58077875f More feedback 2018-11-08 13:14:26 -08:00
Arnold Schwaighofer
963c64e3e7 Add @_private(from: "SourceFile.swift") imports
A module compiled with `-enable-private-imports` allows other modules to
import private declarations if the importing source file uses an
``@_private(from: "SourceFile.swift") import statement.

rdar://29318654
2018-11-08 08:00:47 -08:00
Arnold Schwaighofer
b102c7f6b4 Parser/Sema/SILGen changes for @_dynamicReplacement(for:)
Dynamic replacements are currently written in extensions as

extension ExtendedType {
  @_dynamicReplacement(for: replacedFun())
  func replacement() { }
}

The runtime implementation allows an implementation in the future where
dynamic replacements are gather in a scope and can be dynamically
enabled and disabled.

For example:

dynamic_extension_scope CollectionOfReplacements {
  extension ExtentedType {
    func replacedFun() {}
  }

  extension ExtentedType2 {
    func replacedFun() {}
  }
}

CollectionOfReplacements.enable()
CollectionOfReplacements.disable()
2018-11-06 09:58:36 -08:00
Graydon Hoare
fd226ae761 [ModuleInterface] Address review comments. 2018-11-01 10:51:44 -07:00
Graydon Hoare
9fceeb410e [ModuleInterface] Add FILE_DEPENDENCY record to INPUT_BLOCK. 2018-11-01 10:51:16 -07:00
Jordan Rose
d60f2ff30c Merge pull request #20091 from jrose-apple/deeply-cross
[Serialization] Encode depth for cross-refs to generic parameters
2018-11-01 08:59:42 -07:00
John McCall
cf511445e2 Basic support for Builtin.IntegerLiteral. 2018-10-31 18:42:34 -04:00
Jordan Rose
3455510300 [Serialization] Encode depth for cross-refs to generic parameters
Otherwise, we can't represent a cross-reference to generic parameters
in a parent type /when used in an extension/.

https://bugs.swift.org/browse/SR-9084
2018-10-26 16:51:44 -07:00
Jordan Rose
f3ea8bdd55 [Serialization] Preparation for giving swiftdoc its own version
The functionality change in this commit is that the control block in a
swiftdoc file is validated rather than just being ignored. Tests in
following commit.
2018-10-23 19:55:44 -07:00
Jordan Rose
ae9d86241c [Serialization] Split doc serialization out of the Serializer class
Extract the common utilities into a SerializerBase class, and make a
new DocSerializer.
2018-10-23 19:55:04 -07:00
Jordan Rose
6bcfc783cc [Serialization] Pull swiftdoc serialization out to a separate file
No functionality change.
2018-10-23 19:54:40 -07:00
Graydon Hoare
fa95f7aebd [ModuleInterface] Factor out common AST-layer withOutputFile helper. 2018-10-18 00:31:24 -07:00
Mark Lacey
703341239b Add support for multiple designated types for an operator declaration.
Add parsing, type checking, serialization, and deserialization support
for specifying multiple types as "designated" for operator lookup for
a given operator declaration.

The constraint solver still considers only the first type when
deciding the order to attempt the elements of a disjunction, so this
doesn't really change behavior yet.
2018-10-09 23:54:01 -07:00
Mark Lacey
3c2772a3a7 Fix up naming in some places that I missed. 2018-10-08 08:53:30 -07:00
Mark Lacey
36284ba377 Extend operator decls to allow any designated nominal type for lookup.
Rather than limiting this to protocols, allow any nominal type.

Rename -enable-operator-designated-protocols to
-enable-operator-designated-types to reflect the change.
2018-10-06 17:02:31 -07:00
Harlan
2c86e3249c [InterfaceGen] Print property initializers in resilient, fixed-layout types (#19619)
Augment the ASTPrinter to print the name and text of initializer expressions if
a property has an initializer and the type is @_fixed_layout and resides in a resilient module, and serialize the text for partial modules.

With this change, all .swiftinterface files in the project (except for SwiftLang) compile to swiftmodules on macOS.

rdar://43774580
rdar://43812188
2018-10-05 18:21:46 -07:00
Slava Pestov
3b203a520b Serialization: Don't serialize requirement environment for witnesses
Generic environments and archetypes can be expensive to deserialize
if they involve a generic signature not seen before.

Also, canonicalize the witness substitutions to eliminate type
aliases, and map them to interface types, which again are cheaper
to deserialize.
2018-09-27 22:16:17 -07:00
Graydon Hoare
eda59990cb [SR-8081] Store @_implements synonyms in .swiftmodules. 2018-09-21 14:34:26 -07:00
Slava Pestov
ea1ec895a8 AST: Extended types of extensions should be interface types 2018-09-20 01:20:31 -07:00
Doug Gregor
4ed973329a [SIL] Unify default witness table entries with witness table entries.
SILWitnessTable::Entry already contains a superset of what was supported
by SILDefaultWitnessTable::Entry, the latter of which only had “no entry”
and “method” states. Make SILDefaultWitnessTable::Entry an alias for
SILWitnessTable::Entry, and unify all of the parsing/printing/
(de)serialization logic.
2018-09-15 22:04:46 -07:00
Slava Pestov
8ddd2c02c4 Serialization: Serialize both the substituted and unsubstituted type for a NameAliasType 2018-09-14 14:31:46 -07:00
Harlan
665db876ea [InterfaceGen] Print bodies of inlinable functions in textual interfaces (#19224)
* Introduce stored inlinable function bodies

* Remove serialization changes

* [InterfaceGen] Print inlinable function bodies

* Clean up a little bit and add test

* Undo changes to InlinableText

* Add serialization and deserialization for inlinable body text

* Allow parser to parse accessor bodies in interfaces

* Fix some tests

* Fix remaining tests

* Add tests for usableFromInline decls

* Add comments

* Clean up function body printing throughout

* Add tests for subscripts

* Remove comment about subscript inlinable text

* Address some comments

* Handle lack of @objc on Linux
2018-09-14 10:23:15 -07:00
Saleem Abdulrasool
4baa775726 Merge pull request #19297 from compnerd/unreachable
litter the tree with `llvm_unreachable`
2018-09-14 09:04:56 -07:00
Saleem Abdulrasool
d281b98220 litter the tree with llvm_unreachable
This silences the instances of the warning from Visual Studio about not all
codepaths returning a value.  This makes the output more readable and less
likely to lose useful warnings.  NFC.
2018-09-13 15:26:14 -07:00
Jordan Rose
5fe5391dae [Serialization] Remove the last use of Identifiers for SIL names
The string-keyed tables don't actually need Identifier keys on the
serialization side -- no reason to persist these in the ASTContext's
string table either.
2018-09-13 09:01:08 -07:00
Jordan Rose
09d3dbd3e0 [Serialization] Add a separate string table for non-Identifiers
They're not actually stored separately in the module file, nor
deserialized separately, but this way we're not sticking a bunch of
strings in the /ASTContext's/ string table, which would persist after
serialization. (The ASTContext's string table is also implemented
using a BumpPtrAllocator-backed StringMap, so the performance
characteristics of this should be about the same.)
2018-09-13 09:00:49 -07:00
Slava Pestov
3feaf8731a Serialization: Fix deserialization of generic typealiases
The recovery logic was erronously kicking in, because it was comparing
the substituted underlying type with the declaration's underlying type.

For a generic typealias, these never equal, so instead, serialize the
unsubstituted type, and substitute it in deserialization.
2018-09-11 23:56:16 -07:00