Commit Graph

1088 Commits

Author SHA1 Message Date
Allan Shortlidge
617071447e Merge pull request #68533 from tshortli/serialize-externally-accessible-decls-refactor
Serialization: Use a DeclVisitor to implement deserialization safety
2023-09-15 23:57:04 -07:00
Xi Ge
6f451b9703 Merge pull request #68551 from nkcsgexi/module-name-in-baseline 2023-09-15 18:28:56 -07:00
Xi Ge
95d73171ae ABIChecker: include module name explicitly in generated ABI baseline. NFC 2023-09-15 13:16:46 -07:00
Alexis Laferrière
19271140ef Merge pull request #68523 from xymus/print-public
ModuleInterface: prepare to accept access-level on imports in swiftinterfaces
2023-09-14 19:08:24 -07:00
Allan Shortlidge
1cec6a454f Serialization: Handle precedence groups and operators in ExternallyAccessibleDeclVisitor. 2023-09-14 18:11:03 -07:00
Allan Shortlidge
061578c1a8 Serialization: Handle IfConfigDecls in ExternallyAccessibleDeclVisitor. 2023-09-14 18:09:49 -07:00
Allan Shortlidge
ce58860b0f Tests: Add a typealias test case to lazy_typecheck.swift. 2023-09-14 17:59:17 -07:00
Allan Shortlidge
4522963cf7 Serialization: Handle enum cases in ExternallyAccessibleDeclVisitor. 2023-09-14 17:59:17 -07:00
Alexis Laferrière
3496a74fd9 [ModuleInterface] Print the public keyword on imports in Swift 6 mode
If the access-level on imports proposal is accepted as written, all
imports printed in swiftinterfaces will be `public`. Whether or not we
require the explicit `public` keyword in Swift 6 mode, printing it will
have no downside. It also goes along with the mentality that
swiftinterfaces should be more explicit than implicit.

rdar://115455383
2023-09-14 10:47:37 -07:00
Allan Shortlidge
5e76f76255 ModuleInterface: Ensure implicit accessors are created before printing.
Previously, implicit accessors would be omitted from `.swiftinterface` files
emitted with lazy typechecking enabled.
2023-09-12 09:08:10 -07:00
Allan Shortlidge
9b641f9ba3 ModuleInterface: Typecheck PatternBindingDecls lazily before printing.
Previously, fully qualified types would be missing for global vars and
properties in `.swiftinterface` files that were emitted lazily.

Adding the test case also revealed that PatternBindingDecls needed to be
typechecked before lazy module serialization as well.
2023-09-12 09:08:10 -07:00
Allan Shortlidge
f78b60c529 Tests: Drop unnecessary frontend flags in ModuleInterface/lazy-typecheck.swift
The `-experimental-skip-all-function-bodies` and
`-experimental-serialize-external-decls-only` flags are unnecessary because
this test now uses the `-typecheck` action instead of the `-emit-module`
action.
2023-09-12 09:08:10 -07:00
Allan Shortlidge
7c1b150f39 ModuleInterface: Resolve inherited types when computing unsatisfiable conformances.
Previously, unsatisfiable conformances could be omitted from emitted
`.swiftinterface` files in lazy typechecking mode since inherited types might
be unresolved when gathering the conformances.

Adding these test cases also revealed that serialization restrictions needed to
be relaxed in order to accomodate unsatisfiable conformances.
2023-09-07 13:57:39 -07:00
Allan Shortlidge
eee122c093 ModuleInterface: Resolve inherited types when recording indirect conformances.
Previously, indirect public conformances provided by conforming to an internal
protocol could be skipped in a `.swiftinterface` in lazy typechecking mode
since inherited types might not be resolved before collecting the indirect
conformances.
2023-09-07 13:57:39 -07:00
Allan Shortlidge
435f623caf AST: Resolve types when computing inherited conformances for classes.
Previously, conformances inherited through a base class could be missed in lazy
typechecking mode if types in the inheritance clause were not already resolved.
2023-09-07 13:57:39 -07:00
Allan Shortlidge
fd3714e086 AST: Resolve inherited types in usesFeatureRethrowsProtocol().
Previously, `usesFeatureRethrowsProtocol()` could mistakenly return false in
lazy typechecking mode since the types in an inheritance clause might not have
been resolved yet.
2023-09-07 13:57:39 -07:00
Allan Shortlidge
e24f447eab AST: Resolve types when printing inheritance clauses.
Previously, a `.swiftinterface` emitted in lazy typechecking mode would fall
back on printing the `TypeRepr` of entries in the inheritance clause of a
declaration since inherited types could be unresolved.
2023-09-07 13:57:39 -07:00
Saleem Abdulrasool
99453fc2e8 test: introduce a new %swift-plugin-dir macro
Use this to define the macro location rather than the "host" dir (which
is actually for the build and not the host).  Furthermore, on Windows,
the build dir is /usr/lib/swift as the host content is in the SDK.

This prepares the tests for Windows.
2023-09-04 13:04:18 -07:00
Allan Shortlidge
bc85234e5b Serialization: Don't serialize conformances that should be skipped.
When `-experimental-serialize-external-decls-only` is specified, skip
serializing conformances to protocols that should be skipped to avoid
unnecessary typechecking. Also, ensure type and value witnesses are resolved
lazily during serialization by passing `true` for `useResolver`.

Resolves rdar://114799742
2023-09-01 08:57:33 -07:00
Allan Shortlidge
1b08ab5c67 NFC: Expand -experimental-lazy-typecheck test coverage.
Add classes and constructors to the APIs vended by the `lazy_typecheck` module.
2023-08-31 16:40:18 -07:00
Allan Shortlidge
9a993b64be Tests: Refactor client of the lazy_typecheck module into a shared input.
This allows the ModuleInterface test to attempt to build a client against the
emitted `.swiftinterface` which will help us ensure the emitted interface is
correct.
2023-08-31 16:35:45 -07:00
Allan Shortlidge
99c24b75b4 Tests: Add an -emit-module-interface test case for lazy_typecheck.swift. 2023-08-28 21:22:20 -07:00
Allan Shortlidge
3a02629be4 Frontend: Make lazy typechecking a TC opt instead of a frontend action. 2023-08-28 08:28:56 -07:00
Doug Gregor
ff8a1be972 [Swift interface] Print declarations produced by declaration macro expansion
Don't print the uses of freestanding declaration macros in Swift
interfaces. Instead, print the declarations they produce, as
appropriate.

Fixes rdar://113730928.
2023-08-21 23:31:47 -07:00
Allan Shortlidge
c05b3e4d66 Tests: Adopt -experimental-lazy-typecheck in tests.
Also, restructure the `CHECK:` lines for the `-emit-tbd` test. The number of
columns in the `.tbd` file appears to be variable, so we can't assume a layout
for the symbols in the YAML.
2023-08-18 16:29:56 -07:00
Slava Pestov
c2f1193ae3 Merge pull request #67952 from slavapestov/tuple-conformance-tbd-etc
A pile of mostly unrelated one-liners
2023-08-18 15:31:26 -04:00
Slava Pestov
eadffd3c6c AST: Don't look at PatternBindingDecl in usesBuiltinType()
Type-checking patterns is not fully requestified, so the
ASTPrinter should not assume this has been filled in.

It appears sufficient to just visit the associated VarDecl,
as we do already.
2023-08-18 12:12:50 -04:00
Slava Pestov
010415f4f3 Sema: Force destructor synthesis in evaluateMembersRequest() 2023-08-18 12:12:50 -04:00
Allan Shortlidge
9ecb6b4657 Merge pull request #67980 from tshortli/stop-ignoring-me
Frontend: Migrate several options to no longer be ignorable in swiftinterfaces
2023-08-17 09:51:18 -07:00
Allan Shortlidge
5c762b1435 Frontend: Migrate several options to no longer be ignored in swiftinterfaces.
Frontend options should only be printed under `swift-module-flags-ignored:`
temporarily to prevent condfails for older development compilers that are still
in use (as a rule of thumb, swiftinterfaces should be compatible with compilers
that are up to 6 months old). None of the frontend flags that are currently
categorized as "ignorable" need to be ignorable anymore.
2023-08-16 20:57:50 -07:00
Slava Pestov
21090519a4 Frontend: Allow -emit-module-interface with -resolve-imports
Experimental mode for generating module interfaces without running
primary file type-checking. The idea is that the ASTPrinter triggers
requests to only do the minimum amount of type checking work
possible while printing the interface for a module's public
declarations.

These requests may emit diagnostics, but the ASTPrinter should in
theory already be robust against invalid code.
2023-08-15 19:59:12 -04:00
Pavel Yaskevich
4bd60aeb4e [Tests] NFC: Remove/adjust runtime metadata related test cases 2023-08-15 12:17:31 -07:00
Kavon Farvardin
4e7e6f41cb remove support for _forget, the old spelling of discard
resolves rdar://112549258
2023-08-11 15:42:25 -07:00
Allan Shortlidge
7bb2d82f19 NFC: Update lit.cfg to specify -parse-as-library for module interface tests.
Tests that use the `%target-swift-emit-module-interface` lit substitution are
designed to test the behavior of the compiler when emitting module interfaces
for resilient libraries. It therefore makes sense to pass `-parse-as-library`
by default for these frontend invocations.

Fixes a few tests that were accidentally depending on parsing source files as
top level code.
2023-08-09 14:24:11 -07:00
Pavel Yaskevich
2a0651e8b0 [Frontend/NFC] SE-0400: Enable InitAccessors feature by default 2023-07-31 13:18:59 -07:00
Holly Borla
61e5811d73 [NFC] Update IDE, Index, ModuleInterface, and SourceKit tests to remove
conformance macros.
2023-07-19 12:38:52 -07:00
Doug Gregor
940870e92a Print "conformances" in extension macro role
Fixes rdar://112297735.
2023-07-17 13:47:05 -07:00
Slava Pestov
aa026f4d06 Merge pull request #67266 from slavapestov/transform-type-parameter-packs
Fix various places where we didn't handle "bound" pack references correctly
2023-07-13 08:09:04 -04:00
Xi Ge
45b5b4c13e Merge pull request #67269 from apple/block-list-note
ModuleLoader: emit a note when encountering a blocklisted module interface
2023-07-12 16:55:39 -07:00
Daniel Rodríguez Troitiño
70376a15f0 [ScanDependencies] Fix JSON generation under certain circunstances. (#67246)
The code of `ScanDependencies.cpp` was creating invalid JSON since #66031
because in the case of having `extraPcmArgs` and `swiftOverlayDependencies`,
but not `bridgingHeader`, a comma will not be added at the end of
`extraPcmArgs`, creating an invalid JSON file. Additionally that same PR
added a trailing comma at the end of the `swiftOverlayDependencies`, which
valid JSON does not allow, but that bug was removed in #66366.

Both problems are, however, present in the 5.9 branch, because #66936
included #66031, but not #66366.

Besides fixing the problem in `ScanDependencies.cpp` I modified every test
that uses `--scan-dependencies` to pass the produced JSON through
Python's `json.tool` in order to validate proper JSON is produced. In
most cases I was able to pipe the output of the tool into `FileCheck`,
but in some cases the validation is done by itself because the checks
depend on the exact format generated by `--scan-dependencies`. In
a couple of tests I added a call to `FileCheck` that seemed to be
missing.

Without these changes, two tests seems to be generating invalid JSON in
my machine:

- `ScanDependencies/local_cache_consistency.swift` (which outputs `Expecting ',' delimiter: line 525 column 11 (char 22799)`)
- `ScanDependencies/placholder_overlay_deps.swift`
2023-07-12 14:19:20 -07:00
Xi Ge
b697d40fb6 ModuleLoader: emit a note when encountering a blocklisted module interface 2023-07-12 13:53:36 -07:00
Slava Pestov
29415df860 ASTPrinter: Fix logic to determine if a requirement needs 'repeat' prefix 2023-07-12 12:34:37 -04:00
Artem Chikin
626c32b890 Merge pull request #67009 from Fushj89/inherit-strict-implicit-module-context-in-sub-swiftinterface
should inherit -strict-implicit-module-context when build sub swiftinterface
2023-07-05 12:48:23 -07:00
Ben Barham
1e3aaa57fc [Test] Re-enable distributed-actor
It was `distributed-actors.swift` failing, not
`distributed-actor.swift`. That commit has since been reverted.
2023-07-01 10:49:42 -07:00
Pavel Yaskevich
422fdaa55c Merge pull request #67054 from apple/revert-66852-wip-try-to-make-test
Revert "[Distributed] Try to make test for null sourcefile"
2023-06-30 17:41:31 -07:00
Doug Gregor
139672f854 Merge pull request #67055 from DougGregor/rename-observation-module
[SE-0395] Rename _Observation module to Observation
2023-06-30 13:45:16 -07:00
Steven Wu
94e8ddcf0b Merge pull request #67041 from cachemeifyoucan/eng/PR-fix-cas-depscan-edge-cases
[DepScan][CAS] Fix some cases in cas-based depscanning
2023-06-30 11:41:10 -07:00
Doug Gregor
6265f0c542 [SE-0395] Rename _Observation module to Observation
The review of SE-0395 is down to small details at this point that won't
affect the overall shape of the API much. Rename the model in
anticipation of that.
2023-06-30 11:01:02 -07:00
Pavel Yaskevich
bc9967e998 Revert "[Distributed] Try to make test for null sourcefile" 2023-06-30 10:21:37 -07:00
Steven Wu
dfd11cfec4 [DepScan] Add missing field in JSON output
SwiftSourceModule can contain "commandLine" field and add that into the
JSON output format.
2023-06-30 09:09:27 -07:00