Commit Graph

1116 Commits

Author SHA1 Message Date
Allan Shortlidge
1f48c59ff3 NFC: Use forbidden typechecking prefix in lazy typechecking tests.
Enhance the -experimental-lazy-typecheck suite of tests by adopting
-debug-forbid-typecheck-prefix instead of including broken code in the source
file that would cause diagnostics to be emitted if the compiler typechecks too
much during lazy typechecking. The content of .tbds and .swiftinterfaces
emitted with and without lazy typechecking enabled can now be compared since
the source compiles regardless of mode. This new test regime is less tedious to
maintain and should catch regressions more reliably since it doesn't
require new CHECK lines to be added to several tests every time a new
test case is added in the shared input file.
2023-10-30 14:50:42 -07:00
Xi Ge
09d6944497 ModuleInterface: allow blocklist to configure module names from SDKs that we use textual interfaces exclusively 2023-10-28 14:38:11 -07:00
Apollo Zhu
35d5b68722 Disallow expression macro as default argument
Using as a sub expression in default argument still allowed as expression macros behave the same as built-in magic literals
2023-10-27 05:40:57 -07:00
Allan Shortlidge
33edb6642d Serialization: Resolve type of CustomAttr before serializing.
This fixing a crash during serialization when lazy typechecking is enabled.

Resolves rdar://117442955
2023-10-26 22:46:58 -07:00
Harlan Haskins
4a2eefe2fa Strip comments from inlinable text when printing in swiftinterface files (#69358)
* Strip comments from inlinable text

* Simplify implementation, and avoid trimming trailing whitespace after the comment.

* Update test

* Feedback and handle more cases (with added tests)

* Handle #sourceLocation

* Fix #sourceLocation and fix FileCheck tests
2023-10-25 14:57:22 -06:00
Yuta Saito
43eed0cb8f Merge pull request #69350 from kateinoigakukun/pr-cff728253211b9f0b6cac62756def36ae238e93d
[c-interop] Fix @extern attribute printing for module interface
2023-10-23 21:32:15 -07:00
Yuta Saito
37c71ed7f2 [c-interop] Fix @extern attribute printing for module interface
The new `@extern(c)` was printed without r-paren in swiftinterface.
2023-10-24 01:33:32 +00:00
Rintaro Ishizaki
55144fb302 [Macros] Add test for macro expansion printing
* Macro expanded member decls in .swiftinterface (rdar://117374821)
* cursor-info on a decl with peer macro attribute (rdar://117374966)
2023-10-23 15:21:33 -07:00
Harlan Haskins
4ac34a40ea @retroactive conformance syntax and checking (#36068) 2023-10-20 14:27:03 -07:00
Joe Groff
7dbab5e929 Enable MoveOnlyResilientTypes feature. 2023-10-19 11:46:08 -07:00
Alexis Laferrière
64cd96e629 Merge pull request #69210 from xymus/export-as-module-interface-by-default
ModuleInterface: Always ignore export-as for printing references in private swiftinterfaces
2023-10-17 16:41:37 -07:00
Alexis Laferrière
471b228c1e [ModuleInterface] Test that ModuleInterfaceExportAs doesn't raise errors
Passing the flags `-enable-experimental-feature ModuleInterfaceExportAs`
has no effect anymore, test that it's not reported as an error.
2023-10-16 22:05:26 -07:00
Alexis Laferrière
6f1a774e7d [ModuleInterface] Always ignore export-as in private swiftinterfaces
Always print the real module name for references in private
swiftinterfaces, ignoring export-as declarations. Keep using the
export-as name for the public swiftinterface only.

The flag `ModuleInterfaceExportAs` used to enable this behavior and
we're removing it to make it the default.

rdar://115922907
2023-10-16 13:19:55 -07:00
Alexis Laferrière
b9a7034b2f [Tests] Update swiftinterface imports Swift 6 test
Update the test for imports defaulting to internal by adding the
explicit `public` modifier on all imports and the expected warnings.
Modernized a test somehow as it can't use previously shared files.

This revealed an issue with the warning about superfluous imports on
imports of submodules. I've marked one of them as a FIXME as it will
require a fix in the diagnostic.
2023-10-11 17:18:03 -07:00
Alexis Laferrière
8b098ab487 [Tests] Remove the flag AccessLevelOnImport from all tests but one 2023-10-10 09:09:22 -07:00
Alexis Laferrière
322ada60c8 [Sema] Intro flag to default imports to internal, the Swift 6 mode
The feature InternalImportsByDefault makes imports default to internal instead
of public. Applying the Swift 6 behavior of SE-0409 in Swift 5.

Let's use only that flag to track the Swift 6 behavior as well instead
of separately checking for the language version.
2023-10-10 09:09:21 -07:00
Joe Groff
b4f536927a Disable destructuring initializations in struct let stored properties.
This looks like it was never properly implemented, since when we generate the
memberwise initializer for the struct in SILGen, it incorrectly tries to apply
the entire initializer expression to each variable binding in the pattern,
rather than destructuring the result and pattern-matching it to the variables.
Since it never worked it doesn't look like anyone is using this, so let's
put up an error saying it's unsupported until we can implement it properly.
Add `StructLetDestructuring` as an experimental feature flag so that tests around
the feature for things like module interface printing can still work.
2023-10-03 13:24:39 -07:00
Artem Chikin
08533c94ec Always disable requiring Foundation for '@objc' when building/typechecking interfaces 2023-10-02 10:42:00 -07:00
Doug Gregor
51eed19d4b [Typed throws] Type system support for typed throws.
Add the thrown type into the AST representation of function types,
mapping from function type representations and declarations into the
appropriate thrown type. Add tests for serialization, printing, and
basic equivalence of function types that have thrown errors.
2023-09-29 10:51:53 -07:00
swift-ci
ce36ccd794 Merge pull request #68677 from artemcm/FixImportProcessOrderForScan
[Dependency Scanning] Process implicit imports of the source module first, emulating implicit builds
2023-09-22 12:32:49 -07:00
Artem Chikin
c9c689aec1 [Dependency Scanning] Process implicit imports of the source module first, emulating implicit builds
In case import resolution order somehow sometimes matters, it's prudent to process/resolve/locate implicitly-imported modules first.

Resolves rdar://113917657
2023-09-22 09:40:03 -07:00
Kavon Farvardin
a69bcf8a61 Merge pull request #67930 from kavon/copyable-requirement
Copyable as a Requirement Against the Machine
2023-09-21 11:49:23 -07:00
Kavon Farvardin
cc7a41fc2c [stdilb] introduce Copyable protocol
This replaces the old, unavailable `_Copyable`.

rdar://110420673
2023-09-21 00:55:17 -07:00
swift-ci
8b97d43de6 Merge pull request #68598 from artemcm/ExplicitInterfaceTypecheckFix
[Explicit Modules] Fix detection of a type-checking action in `ExplicitModuleInterfaceBuilder`
2023-09-19 14:52:27 -07:00
Artem Chikin
373d49134a [Explicit Modules] Fix detection of a type-checking action in 'ExplicitModuleInterfaceBuilder'
When we run an interface verification tasks with Explicit module builds, we directly invoke a '-explicit-interface-module-build' instance with a '-typecheck-module-from-interface' action. So the builder needs to recognize this as a typechecking invocation. In implicit builds, this gets lowered into a separate compiler sub-instance with a '-typecheck' action, for some reason.

resolves rdar://115565571
2023-09-19 10:38:42 -07:00
Alexis Laferrière
a24d377b68 Merge pull request #68591 from xymus/print-public-fix
[ModuleInterface] Extract the test of the Swift 6 variant from imports.swift
2023-09-19 08:20:34 -07:00
Alexis Laferrière
eaf74b280b [ModuleInterface] Extract the Swift 6 variant from imports.swift
This allows us to limit the test to asserts compiler supporting
-swift-version 6.

rdar://115578753
2023-09-18 10:54:35 -07:00
Allan Shortlidge
497034ef64 AST: Requestify generic signature building for @_specialized attributes.
In order to support lazy typechecking during module emission for modules
containing specialized functions, the computation of generic signatures for
`@_specialized` attributes must be requestified.

Resolves rdar://115569606
2023-09-16 00:02:33 -07:00
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