Commit Graph

645 Commits

Author SHA1 Message Date
Holly Borla
11028350a7 Merge pull request #35589 from Jumhyn/placeholder-types
[AST, Sema] Replace HoleType with PlaceholderType
2021-02-22 08:35:37 -08:00
Doug Gregor
66cd7d82ae Marker protocols are self-conforming. 2021-02-18 23:44:39 -08:00
Frederick Kellison-Linn
a5d0153fbf [AST] Assume that placeholder types conform to all protocols 2021-02-16 22:59:19 -05:00
Becca (née Brent) Royal-Gordon
e6aee251be Merge pull request #35904 from beccadax/go-back-to-the-shadow
Warn about module name shadowing in interfaces
2021-02-16 15:32:41 -08:00
AG
a5b804602d Merge pull request #35110 from bitjammer/acgarland/emit-symbol-graph
Add optional -emit-symbol-graph output when emitting modules
2021-02-12 09:00:58 -08:00
Becca Royal-Gordon
c2f3725f56 Warn about module name shadowing in interfaces
There is a known issue with module interfaces where a type with the same name as a module will disrupt references to types in that module. Fully fixing it will require a new language feature (SR-898) which is not yet available. In the meantime, module interfaces support a workaround flag (“-Xfrontend -module-interface-preserve-types-as-written”) which prints an alternate form that usually works. However, you have to know to add this flag, and it’s not obvious because nothing breaks until a compiler tries to consume the affected module interface (or sometimes even one of its clients).

This commit emits a warning during module interface emission whenever the module interface either imports a type with the same name as the module being built, or declares a type with the same name as a visible module. This lets the user know that the type may cause problems and they might need to implement a workaround.
2021-02-10 19:03:06 -08:00
Robert Widmann
b960c6e31c Derive a Fingerprint from a Module's BasicSourceFileInfo 2021-02-02 09:57:46 -08:00
Robert Widmann
7c5f8a0e6c [NFC] Const-qualify BasicSourceFileInfo 2021-02-02 09:57:04 -08:00
Ashley Garland
69c4fc47cb Add optional -emit-symbol-graph output when emitting modules
rdar://71497047
2021-01-28 09:55:33 -08:00
Robert Widmann
73ac8d3531 Replace llvm::MD5 with StableHasher 2021-01-21 17:19:38 -08:00
Erik Eckstein
e3d636e519 CrossModuleOptimization: fix crash when importing a module as implementationOnly
If a function uses a type imported as implementationOnly (or similar), it cannot be serialized.

I added a new API in ModuleDecl (canBeUsedForCrossModuleOptimization), which performs this check.

rdar://72864719
2021-01-18 13:09:27 +01:00
Ben Barham
b6aedc75f8 Merge pull request #35441 from bnbarham/allow-delayed-parsing-with-interface-hash
[Parser] Keep delayed body parsing even with interface hash generation
2021-01-16 13:25:38 +10:00
Ben Barham
4be504673e [Parser] Keep delayed body parsing even with interface hash generation
The generated hash ignores tokens parsed in the body anyway, so there's
no reason to disable delayed body parsing in this case.
2021-01-15 10:17:12 +10:00
Rintaro Ishizaki
a9a044c6e3 [Serialization] Serialize fingerprint, mtime, size of the source files 2021-01-13 11:49:52 -08:00
Rintaro Ishizaki
09121f7780 [AST] Move getInterfaceHashIncludingTypeMembers() to SourceFile 2021-01-13 11:49:52 -08:00
Rintaro Ishizaki
1b6e7857c2 [Serialization] Serialize/deserialize source file list 2021-01-13 11:49:52 -08:00
Slava Pestov
d1a2a612b1 AST: Change some writeDependencySink() methods to take the result by const reference 2020-12-22 01:42:04 -05:00
Arnold Schwaighofer
2b6ba2830c Serialize decls with _specialize(exported:true, target: somefunc(_:), ...) in a list for fast lookup
rdar://71430641
2020-12-11 09:58:32 -08:00
Robert Widmann
883902411b Migrate loadFingerprint onto ModuleDecl and Friends 2020-11-18 12:20:14 -08:00
Robert Widmann
912ed2711b [NFC] Use Fingerprints When Computing the Interface Hash 2020-11-18 12:20:14 -08:00
Artem Chikin
3b545498d0 Merge pull request #34331 from artemcm/NoFoundationOnExplicitImportSoil
[Clang Importer] Do not rely on being able to always import Foundation on-demand
2020-11-02 13:02:15 -08:00
Alejandro Alonso
424802fb34 Revert SE-0283 (#34492)
Reverted despite build failures.
2020-10-29 17:32:06 -07:00
Artem Chikin
0305f20f32 [Clang Importer] Do not rely on being able to always import Foundation on-demand
When importing Clang types.
This is not an option with Explicit Module Builds. If the module being built does not (directly or transitively) depend on `Foundation`, then attempting to load it will produce an error because Implicit module loading is no longer allowed..

This change addresses a small number of cases where ClangImporter relies on being able to load `Foundation` on-demand:
- When importing a single Decl from a clang module, we check whether it has certain conformances by checking all extensions of the NominalTypeDecl of the Decl in question, to see if any of the extensions contain the conformance we are looking for, but we only check extensions whose parent module is either the original module of the NominalTypeDecl or the overlay module of the NominalTypeDecl or Foundation. It seems that we do not need to actually import `Foundation` here, just checking the module Identifier should be sufficient.
- In `maybeImportNSErrorOutParameter`, change the behavior to have an exit condition based on whether `Foundation` can be imported, before attempting to load it.
- When checking whether or not we are allowed to bridge an Objective-C type, it also looks sufficient the query whether or not `Foundation` *can* be imported, without loading it.
2020-10-28 14:47:17 -07:00
Varun Gandhi
d32a371df5 Merge pull request #34410 from varungandhi-apple/vg-revert-import-filtering-refactor
Revert "[NFC] Clarify semantics of getImportedModules."
2020-10-26 13:36:32 -07:00
Varun Gandhi
1f479896f4 Revert "[NFC] Clarify semantics of getImportedModules."
This reverts commit 4b5d885114.
2020-10-23 10:01:35 -07:00
Azoy
4ff28f2b40 Implement Tuple Hashable Conformance 2020-10-22 18:28:02 -04:00
Azoy
fd950ebbf3 Implement Tuple Comparable Conformance
Add protocol witnesses for all Comparable requirements
2020-10-22 18:27:07 -04:00
Azoy
e60ef84bd2 Implement Tuple Equatable Conformance 2020-10-22 18:24:28 -04:00
Arnold Schwaighofer
2a2cf91dcd Add support for marking a _specialize attribute as SPI
```
  @_specialize(exported: true, spi: SPIGroupName, where T == Int)
  public func myFunc() { }
```

The specialized entry point is only visible for modules that import
using `_spi(SPIGroupName) import ModuleDefiningMyFunc `.

rdar://64993425
2020-10-12 09:19:29 -07:00
Brent Royal-Gordon
d55c5bd549 [NFC] Add type for ModuleDecl::getImplicitImports()
This doesn’t really change the design yet.
2020-10-09 18:58:03 -07:00
Brent Royal-Gordon
c489fffb79 [NFC] Rename and document fields of AttributedImport
Also renames a member in ImportResolution.cpp to align with this naming.
2020-10-09 18:57:07 -07:00
Brent Royal-Gordon
f3d99cefbb [NFC] Turn ImportedModuleDesc into AttributedImport
Rename ImportedModuleDesc to AttributedImport and make it a template that’s parameterized on the representation of the module. This will allow us to reduce duplicated representations of “abstract” ImportDecls.
2020-10-09 18:57:07 -07:00
Brent Royal-Gordon
b440ab7331 [NFC] Move several types/functions to Import.h
To help consolidate our various types describing imports, this commit moves the following types and methods to Import.h:

* ImplicitImports
* ImplicitStdlibKind
* ImplicitImportInfo
* ModuleDecl::ImportedModule
* ModuleDecl::OrderImportedModules (as ImportedModule::Order)
* ModuleDecl::removeDuplicateImports() (as ImportedModule::removeDuplicates())
* SourceFile::ImportFlags
* SourceFile::ImportOptions
* SourceFile::ImportedModuleDesc

This commit is large and intentionally kept mechanical—nothing interesting to see here.
2020-10-09 18:57:07 -07:00
Robert Widmann
f1f5961e0f [NFC] Add Incremental Info Bits to ModuleDecl 2020-09-24 20:07:01 -06:00
Varun Gandhi
4b5d885114 [NFC] Clarify semantics of getImportedModules.
The lack of clarity manifested as unexpected behavior when using
getImportedModules to create the module import graph. The new behavior
makes SPI-ness and Shadowing-ness behave similarly in terms of
filtering. We also check if a filter is well-formed to avoid
accidental empty import lists.
2020-09-23 12:50:37 -07:00
Varun Gandhi
d3369f7711 [NFC] Rename ImportFilterKind cases to be clearer. 2020-09-23 12:50:20 -07:00
Brent Royal-Gordon
6f2853695b [NFC] Delete obsolete AccessPathTy-based code
This was all deprecated in earlier commits.
2020-09-10 19:08:29 -07:00
Brent Royal-Gordon
cff4ddf13a [NFC] Adopt new ImportPath types and terminology
# Conflicts:
#	lib/IDE/CodeCompletion.cpp
2020-09-10 19:07:49 -07:00
Alexis Laferrière
cbb7228451 [Sema] Evaluate SPI groups for all decls, not only public ones
Remove the fast path skipping evaluating SPI groups for non-public
decls. This knowledge is still required to allow the use of SPI types in
the signatures of `@usableFromInline` declarations and in internal
properties of structs in non library evolution compilation.

rdar://68530659
rdar://68527580
2020-09-08 16:58:45 -07:00
Slava Pestov
193cf0de87 Code review feedback from @davidungar 2020-09-04 19:59:17 -04:00
Slava Pestov
4923aab2ea AST: Add hoisted declarations to unqualified name lookup cache 2020-09-03 16:16:50 -04:00
Slava Pestov
fae8f944b8 AST: Add 'hoisted' flag to Decl 2020-09-03 16:16:50 -04:00
Alexis Laferrière
fd78da5137 [ModuleInterface] Don't print extensions to implementation-only imported types
Extensions to implementation-only types are accepted at type-checking
only if they don't define any public members. However if they declared a
conformance to a public type they were also printed in the
swiftinterface, making it unparsable because of an unknown type.

Still accept such extensions but don't print them.

rdar://problem/67516588
2020-08-20 17:12:31 -07:00
David Zarzycki
1e940c2c7e [NFC] Fix -Wsuggest-override warnings
LLVM, as of 77e0e9e17daf0865620abcd41f692ab0642367c4, now builds with
-Wsuggest-override. Let's clean up the swift sources rather than disable
the warning locally.
2020-08-13 16:17:46 -04:00
Rintaro Ishizaki
513fed7d8c [CodeCompletion] Enable ASTScope in code completion
* Re-create `ASTScope` for each completion
* Add generic params and where clause scope even without missing body
* Use `getOriginalBodySourceRange()` for `AbstractFunctionBodyScope`
* Source range translations for replaced ranges when finding scopes
* Bypass source range checks when the completion happens in the replaced
  range
* Be lenient with ASTScope / DeclContext mismatch in code completion
2020-08-12 16:36:09 -07:00
Matei Oprea
6ae04f749b [NFC] Remove ModuleDecl::isClangModule in favor of isNonSwiftModule. (#33202)
Fixes SR-13237.
2020-08-03 20:01:17 -07:00
Nikhil
96587bc2d4 Refactor construction of ModuleDecl::ImportFilters to use new initializer list constructor (#33250)
This commit makes code cleaner by using newly introduced
 initializer list construction
2020-08-01 14:24:44 -07:00
Brent Royal-Gordon
4394e92c3f Merge pull request #32700 from brentdax/magical-and-evolutionary
Revise #file changes from SE-0274
2020-07-17 01:57:23 -07:00
Alexis Laferrière
47e4e29362 [Sema] SPI info on a wrapped property should propagate to the backing storage 2020-07-16 14:47:28 -07:00
Brent Royal-Gordon
0e569f5d9e Add support for #fileID
This temporarily breaks -enable-experimental-concise-pound-file.

fixup adding #fileID
2020-07-13 14:05:13 -07:00