Commit Graph

1116 Commits

Author SHA1 Message Date
Alexis Laferrière
c8ca517e56 [ModuleInterface] Don't alias the stdlib or builtin module
Not aliasing the stdlib should allows it to be used in inlinable code.
Since builtin isn't imported explicitly, references to it shouldn't use
the alias.

rdar://104582241
2023-01-23 17:52:37 -08:00
Alexis Laferrière
32d4edad22 [ModuleInterface] Don't alias @_spiOnly imports in public swiftinterfaces 2023-01-23 17:41:11 -08:00
Doug Gregor
43cadcad3a [Macros] Serialization and printing for @attached. 2023-01-14 21:48:43 -08:00
John McCall
55b72d4eb7 Fix the pretty-printing of pack expansion types to match the current design 2023-01-11 03:11:30 -05:00
Holly Borla
6725f365ba [Variadic Generics] Update tests for syntax changes. 2023-01-07 09:50:14 -08:00
Allan Shortlidge
8e46b76882 NFC: Update @_backDeploy tests to remove @available attributes where possible. 2023-01-06 08:18:00 -08:00
Pavel Yaskevich
0987eff828 [Sema] TypeWrappers: Availability of init(storageWrapper:) should match that of $Storage 2023-01-04 16:04:28 -08:00
Doug Gregor
7000969f14 Introduce and use #externalMacro for externally-defined macros.
Align the grammar of macro declarations with SE-0382, so that macro
definitions are parsed as an expression. External macro definitions
are referenced via a referenced to the macro `#externalMacro`. Define
that macro in the standard library, and recognize uses of it as the
definition of other macros to use externally-defined macros. For
example, this means that the "stringify" macro used in a lot of
examples is now defined as something like this:

    @expression macro stringify<T>(_ value: T) -> (T, String) =
        #externalMacro(module: "MyMacros", type: "StringifyMacro")

We still parse the old "A.B" syntax for two reasons. First, it's
helpful to anyone who has existing code using the prior syntax, so they
get a warning + Fix-It to rewrite to the new syntax. Second, we use it
to define builtin macros like `externalMacro` itself, which looks like this:

    @expression
    public macro externalMacro<T>(module: String, type: String) -> T =
        Builtin.ExternalMacro

This uses the same virtual `Builtin` module as other library builtins,
and we can expand it to handle other builtin macro implementations
(such as #line) over time.
2023-01-02 21:22:05 -08:00
Doug Gregor
6bb9cb8b5d [Macros] Always parse macro expansions, diagnose later
Always parse macro expansions, regardless of language mode, and
eliminate the fallback path for very, very, very old object literals
like `#Color`. Instead, check for the feature flag for macro
declaration and at macro expansion time, since this is a semantic
restriction.

While here, refactor things so the vast majority of the macro-handling
logic still applies even if the Swift Swift parser is disabled. Only
attempts to expand the macro will fail. This allows us to enable the
macro-diagnostics test everywhere.
2023-01-02 21:22:04 -08:00
Doug Gregor
f78f5729c3 Start requiring expression macros to be marked with @expression 2022-12-22 09:18:05 -08:00
Erik Eckstein
21b4004d69 Devirtualizer: don't de-virtualize witness calls to non-generic thunks which call a generic function.
If the callee is a non-generic thunk which calls a (not inlinable) generic function in the defining module,
it's more efficient to not devirtualize, but call the non-generic thunk - even though it's done through the witness table.
Example:
```
  protocol P {
    func f(x: [Int])   // not generic
  }
  struct S: P {
    func f(x: some RandomAccessCollection<Int>) { ... } // generic
  }
```

In the defining module, the generic conformance can be fully specialized (which is not possible in the client module, because it's not inlinable).

rdar://102623022
2022-12-21 08:52:53 +01:00
swift-ci
6ccb39009d Merge pull request #62688 from adrian-prantl/102367872-1
Ensure unique names in ParameterList::clone()
2022-12-19 16:32:08 -08:00
Adrian Prantl
9e22b70cff Ensure unique names in ParameterList::clone()
IRGenDebugInfo assumes that all argument names within the same scope are unique
as it uses them as a key in a hash table.

rdar://102367872
2022-12-19 09:50:08 -08:00
Pavel Yaskevich
4e6e6bd29e [Tests] NFC: Add assertions requirement to a type wrapper test
Resolves: rdar://103452169
2022-12-16 10:34:05 -08:00
Pavel Yaskevich
7b08b30e84 Merge pull request #62586 from xedin/rdar-103270262
[AST/Sema] TypeWrappers: Fix a couple of issues with attribute inference from protocols
2022-12-15 17:49:19 -08:00
Pavel Yaskevich
5c11a4b894 [ASTPrinter] TypeWrappers: print inferred attributes 2022-12-14 17:50:28 -08:00
Doug Gregor
3be6344619 Eliminate dependencies on _SwiftSyntaxMacros having actual macros in it 2022-12-14 16:13:48 -08:00
Pavel Yaskevich
a8d8cf0682 [TypeChecker] TypeWrappers: Set access level for $Storage/$storage based on protocol conformances
If a type conforms to a protocol that has a public `$Storage`/`$storage`
requirement the synthesis should produce a public `$Storage`/`$storage`
implementation as well to match the requirement.

Resolves: rdar://103270262
2022-12-14 12:26:53 -08:00
Alexis Laferrière
ab38752d33 [ModuleInterface] Ignore export_as in private swiftinterface
Introduce a new behavior when printing references to modules with an
`export_as` definition. Use the `export_as` name in the public swiftinterface
and the real module name in the private swiftinterface.

This has some limits but should still be an improvement over the current
behavior. First, the we use the `export_as` names only for references to clang
decls, not Swift decls with an underlying module defining an `export_as`.
Second, we always print the `export_as` name in the public swiftinterface,
even in the original swiftinterface file when the `export_as` target is likely
not know, so that generated swiftinterface is still broken.

This behavior is enabled by the flags `-enable-experimental-feature ModuleInterfaceExportAs`
or the `SWIFT_DEBUG_USE_EXPORTED_MODULE_NAME_IN_PUBLIC_ONLY` env var. We may
consider turning it on by default in the future.

rdar://98532918
2022-12-12 14:58:19 -08:00
Anthony Latsis
d553d0466a Merge pull request #62355 from AnthonyLatsis/sr-no-sr
[NFC] Migrate remnant Jira issue references to GitHub issues
2022-12-04 12:08:25 +03:00
Anthony Latsis
4cb63c8a0f [NFC] Migrate remnant Jira issue references to GitHub issues 2022-12-04 08:20:34 +03:00
Slava Pestov
2ebddf5817 Merge pull request #62180 from slavapestov/printing-variadic-types
Fixes for printing variadic generic types
2022-12-02 16:01:13 -05:00
Slava Pestov
b2285f58d7 ASTPrinter: Fix printing variadic BoundGenericTypes 2022-12-02 11:15:43 -05:00
Evan Wilde
5f9ac391be Requires-asserts macro tests
Macros are an experimental feature, as such are not available on
non-asserts compilers.

Adding requires asserts to remaining experimental macro tests.
 - ModuleInterface/macros.swift
 - Serialization/macros.swift
2022-12-01 11:18:10 -08:00
Doug Gregor
1a124e71d6 [Macros] Implement AST printing and module interface generation for macros 2022-11-28 18:33:10 -08:00
Xi Ge
afbc4a5ffd Merge pull request #62251 from nkcsgexi/allowable-serialization
serialization: encode allowable client names in binary module format
2022-11-28 18:12:43 -08:00
Alexis Laferrière
c266e9dce5 Merge pull request #62185 from xymus/improve-rmodule-loading
Improve `-Rmodule-loading` to show both the path to the source and to the cached file actually loaded
2022-11-28 14:25:15 -08:00
Xi Ge
67bbab7e02 serialization: encode allowable client names in binary module format 2022-11-25 18:43:40 -08:00
Alexis Laferrière
319d49816d [Frontend] -Rmodule-loading shows both source path and cached path 2022-11-18 15:28:16 -08:00
Xi Ge
889c543e7f Merge pull request #62166 from nkcsgexi/allowable-client-flag 2022-11-17 23:13:35 -08:00
Xi Ge
7d6cc1875d Frontend: add module interface flag to specify allowable clients
This new flag should allow module authors to specify allowable client list. This list is printed
in the textual module interface. Diagnostics support can come later.
2022-11-17 20:00:40 -08:00
Alexis Laferrière
888fe84013 Merge pull request #62073 from xymus/module-alias-disambiguate-more
[ModuleInterface] AliasModuleNames workaround support for indirect dependencies and missing imports
2022-11-17 10:33:56 -08:00
Alexis Laferrière
7ae02c02f5 [ModuleInterface] Always use the real name for modules not imported directly
In AliasModuleNames, avoid wrongfully printing aliased names for modules
that were not aliased. This can happen in the case of modules indirectly
imported via a reexport.

rdar://102262019
2022-11-16 10:40:55 -08:00
Artem Chikin
729ad402df [Dependency Scanning] Produce canonical output path for Swift binary modules.
Instead of relying on the client (driver) to perform its own computation of the matching output path.
2022-11-15 11:08:13 -08:00
Artem Chikin
5e208ff30e Merge pull request #62067 from artemcm/DepScanClangOutputPath
[Dependency Scanning] Produce canonical output path for Clang PCMs.
2022-11-15 08:39:04 -08:00
Artem Chikin
dc7cae21d2 [Dependency Scanning] Produce canonical output path for Clang PCMs.
Instead of relying on the client (driver) to perform its own computation of the matching output path.
2022-11-14 13:53:40 -08:00
Slava Pestov
a72ce0076c Disable variadic generics tests on noasserts builds
Fixes rdar://problem/102300174.
2022-11-14 12:14:23 -05:00
Slava Pestov
07b0c5c948 ASTPrinter: Print shape requirements in a way that parses 2022-11-12 02:13:54 -05:00
Alexis Laferrière
b526205f42 Merge pull request #62044 from xymus/module-alias-disambiguate-fix
[ModuleInterface] Support loading an aliased module with an underlying module
2022-11-11 11:55:44 -08:00
Alexis Laferrière
a1270f66cc [Serialization] Support loading an aliased module with an underlying module
Importing a module using an alias (set with -module-alias) fails if the
imported module has an underlying clang module.

rdar://102217790
2022-11-10 16:30:35 -08:00
Artem Chikin
2a84d6de1b Merge pull request #61919 from artemcm/InheritExtraClangStateForInterfaceSubInvocation
Inherit parent's extra Clang arguments when creating an interface build sub-invocation.
2022-11-09 09:24:18 -08:00
Allan Shortlidge
7782f862c0 Sema: Avoid adding nonisolated twice to synthesized Hashable methods.
https://github.com/apple/swift/pull/42041 introduced a centralized mechanism for adding the `nonisolated` attribute to synthesized decls but did not clean up the existing code that was already doing so for `Hashable` conformances.

Resolves rdar://102106591
2022-11-08 18:35:27 -08:00
Artem Chikin
d1cbf9c8d4 Inherit parent's extra Clang arguments when creating an interface build sub-invocation.
We would like to make sure they get propagated to downstream transitive Clang module dependencies also.

Resolves rdar://101923680
2022-11-08 09:32:30 -08:00
Slava Pestov
d88e70132a AST: Print parameterized protocols in opaque return types
The primary change was the refactoring of ArchetypeType::getExistentialType();
this commit just fixes the type sugar.

Fixes rdar://problem/100911362.
2022-11-07 18:38:06 -05:00
Alexis Laferrière
66586b5f63 [ModuleInterface] Print alias for module names in swiftinterface files
Ambiguities are introduced in generated swiftinterfaces when a type
shares a name with a module (i.e. XCTest). This workaround uses the
module-alias feature to avoid these ambiguities. Writing module
references with a distinguishable prefix should allow normal
type-checking to avoid the usual ambiguities.

We should still aim for a proper fully-qualified named syntax, but this
may help in the mean time.

rdar://101969500
2022-11-04 12:30:33 -07:00
Alexis Laferrière
1ce67099de [ModuleInterface] Support aliasing a module loaded from a swiftinterface 2022-11-04 11:10:59 -07:00
Alexis Laferrière
fec0498c65 [Test] Use a clean module cache for more tests
Use a clean module cache in tests printing path to the
swiftmodule/swiftinterface used as it may change depending on previous
tests.
2022-10-31 10:58:56 -07:00
Artem Chikin
625048a43f Merge pull request #61545 from artemcm/PropagateApplicationExtensionStatus
Propagate '-application-extension' to module interface loader sub-invocations.
2022-10-13 08:51:23 -07:00
Artem Chikin
0c470f238b Propagate '-application-extension' to module interface loader sub-invocations.
This flag restricts availability of certain symbols to ensure the code cannot use declarations that are explicitly unavalable to extensions. This restriction should be passed down to dependency modules also.
2022-10-11 11:24:48 -07:00
Allan Shortlidge
8d10065b50 Test: Add availability annotations to ModuleInterface/global-actor.swift. 2022-10-03 17:22:44 -07:00