Follow-up to https://github.com/swiftlang/swift/pull/88733,
enabling the example in rdar://172511809 ([nonescapable] Allow a
nonescaping function to be a lifetime dependency source):
```swift
@_lifetime(body) // Inferred dependence kind: copy
func foo(body: () -> Span<Int>) { body() }
```
or
```swift
// Inferred: @_lifetime(copy body)
func foo(body: () -> Span<Int>) { body() }
```
Follow-up: Consider also disallowing borrow dependence on `@noescape`
closures.
<!--
If this pull request is targeting a release branch, please fill out the
following form:
https://github.com/swiftlang/.github/blob/main/PULL_REQUEST_TEMPLATE/release.md?plain=1
Otherwise, replace this comment with a description of your changes and
rationale. Provide links to external references/discussions if
appropriate.
If this pull request resolves any GitHub issues, link them like so:
Resolves <link to issue>, resolves <link to another issue>.
For more information about linking a pull request to an issue, see:
https://docs.github.com/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
-->
<!--
Before merging this pull request, you must run the Swift continuous
integration tests.
For information about triggering CI builds via @swift-ci, see:
https://github.com/apple/swift/blob/main/docs/ContinuousIntegration.md#swift-ci
Thank you for your contribution to Swift!
-->
---------
Co-authored-by: Andrew Trick <atrick@apple.com>
@_preInverseGenerics(except: <inverses>) is an extension of the existing
@_preInverseGenerics attribute that provides selective control over which
inverse requirements are mangled into a declaration's symbol name.
While the bare @_preInverseGenerics strips all inverse constraints
(~Copyable and ~Escapable) from mangling, the 'except:' form allows specific
inverses to be retained. This is needed when a type like Span already had
~Copyable mangled into its ABI-stable symbols and now needs to retroactively
adopt ~Escapable without changing those existing symbols. You can now express
that with `@_preInverseGenerics(except: ~Copyable)` to strip-out every inverse
except ~Copyable to preserve the pre-existing ~Copyable-containing symbols.
It requires the new experimental feature `PreInverseGenericsExcept`.
rdar://176395527
Previously, the synthesis set the access of the setter of a newly
synthesized projected value property to match that of the parent
property setter, but `projectedValue` of the property wrapper could
be less accessible than that and the synthesis needs to account
for that. Otherwise, the interface file might get a setter printed
even though it's not part of the ABI.
Resolves: rdar://176978806
Now that module selectors (SE-0491) are used by default when printing
.swiftinterface files, the following warning is unnecessary:
```
public struct <name> shadows module <name>, which may cause failures...
```
Remove the implementation of the warning entirely. Technically, we could keep
diagnosing the issue when use of module selectors in .swiftinterface files is
disabled via the `-disable-module-selectors-in-module-interface` flag, but on
balance it does not seem worth it since we don't anticipate any uses of that
flag aside from temporarily working around compiler bugs.
Resolves rdar://176476640.
If a decl written in source has `override` because it overrides a `package`
decl, then the `override` keyword should be printed in the
`.package.swiftinterface` since the overridden decl is visible.
Resolves rdar://158178648.
Add test cases for various edge cases related to conformances with
MemberImportVisibility enabled. Missing imports that break conformances should
be diagnosed, but those diagnostics should not prevent certain accepted
conformances from continuing to be accepted.
Tests only, NFC.
The @diagnose attribute only affects local diagnostic behavior within a declaration's body and has no API or ABI impact. It should not appear in .swiftinterface files, and should not cause declarations to be wrapped in #if $SourceWarningControl feature guards.
When a requirement witnesses itself that indicates that no witness was found
and the conformance checker is treating the witness as "opaque". The visibility
of the requirement should not be diagnosed.
Follow up to https://github.com/swiftlang/swift/pull/88616.
Resolves rdar://175691719.
Conformance checking in swiftinterfaces is lenient and can recover from missing
witnesses by assuming that the protocol witness table will have an entry for
the requirement at runtime. As a result, diagnosing missing imports for
witnesses here could break source compatibility for existing interface files
and must be skipped. This fixes a regression introduced by
https://github.com/swiftlang/swift/pull/88470.
Resolves rdar://175215763.
Makes it possible for users of `-warnings-as-errors` to control the behavior of
warnings about the obsoletion of module interface emission options.
Resolves rdar://174787052.
The `@export(interface)` and `@export(implementation)` attributes
SE-0497 are queried directly on AST nodes in several places within the
SIL pipeline. However, they don't persist when SIL functions are
serialized, meaning that clients of the original module might make
different assumptions about the availability of a given function's
definition.
Represent these attributes in a SIL function (as an optional
CodeGenerationModel), (de-)serialize them into the module, and add a
textual representation as SIL function attributes `[export_interface]`
and `[export_implementation]`.
Back in January, I updated the swiftinterface _reading_ code to accept either
`read`/`modify` or `yielding borrow`/`yielding mutate`. That update has been
around for long enough that we can now switch over the swiftinterface _writing_
code to emit the standard final `yielding borrow`/`yielding mutate` spellings.
Interface files written with the old spellings will continue to be
accepted for some time (likely a year or more).
The only known condfail scenario is inheriting from
a protocol P that inherits from a reparentable one R.
We already guard P if it mentions R in its inheritance clause.
So older compilers will simply report that "P" is missing in the
interface, which is a better error message than virally guarding
everything mentioning P. It's an ABI break anyway to do that
without introducing a `@reparented` extension, which needs a guard.
In theory, older compilers shouldn't have too much go wrong if they
were to ignore `@reparentable`, though the RequirementMachine and
witness tables will look different.
rdar://174263176
As a follow up to https://github.com/swiftlang/swift/pull/87832, continue
adjusting the algorithm for computing synthesized conformance availability.
When an outer declaration is `unavailable` in a more specific platform domain
and the inner declaration is `introduced:` in a less specific domain, the inner
declaration attribute does not override the outer declaration attribute.
Unavailability and introduction on separate axes of availability.
Resolves rdar://173724423.
The compiler synthesizes an `unownedExecutor` property for every `actor` type.
It was also synthesizing availability attributes for this property by
intersecting the availability of the actor type and the `UnownedExecutor` type.
This may have been necessary early in the development of Swift Concurrency but
now it amounts to little more than a convoluted procedure that must result in
repeating the availability of the actor on one of its properties (the property
can never be less available than the actor itself).
When printing `.swiftinterface` files, implicit conformances may need to be
printed with inferred availability attributes. The existing algorithm for
determining which availability attributes to print needed a few updates to
better handle `anyAppleOS` availability attributes:
- `@available(anyAppleOS, ...)` attributes attached to a nested declaration
should take priority over platform-specific `@available` attributes on outer
declarations.
- At the same time, `@available(anyAppleOS, ...)` attributes attached to the
_same_ declaration as a platform-specific `@available` attribute should not
take priority. Instead, both attributes should be included in the inferred
set.
Default to use new swift-driver to run lit tests as legacy swift driver
is deprecated for a long time. The lit tests for legacy drivers are also
disable when running new swift-driver.
Tests that relies on legacy swift driver (for example, tests merge
module) can be enabled on conditions `legacy_swift_driver`. Fix and
split up some existing tests that relies on legacy driver.
This change fixes rdar://172417385 and #45125 by using transformRec
to set no escape, instead of casting which drops sugar. This affects
how interfaces are printed, and could theoretically cause issues with
printing private aliases into public interfaces. Motivated by needing
to be able to diagnose issues with attributes on aliases; without this
change, the alias sugar is sometimes lost.
Compute and propagate the library level (api/spi/ipi) of each module
dependency through the dependency scanner so that the compiler can
correctly enforce private module import diagnostics in CAS mode, where
path-based SPI detection fails because CAS abstracts file paths to
content IDs.
Swift modules:
- Detect library level from the module interface path using
libraryLevelFromPath() during scanning, for both textual (.swiftinterface)
and binary (.swiftmodule) Swift modules.
Clang modules:
- Expose ModuleMapIsPrivate from clang::Module in ModuleDeps via the
dependency scanning infrastructure.
- Set library level for clang modules in bridgeClangModuleDependency()
using ModuleMapIsPrivate (catches module.private.modulemap in any
SDK location) and libraryLevelFromPath() on the module map file
(catches modules under PrivateFrameworks directories).
The library level is:
- Stored in ModuleDependencyInfo and serialized in the module dependency
cache (format version bumped to v8).
- Exposed through the swiftscan C API via a new
swiftscan_module_info_get_library_level() function (API minor version
bumped to 3).
- Emitted in the dependency scanner JSON output as "libraryLevel" for
all module kinds (Swift textual, Swift binary, Clang, and main module).
- Parsed from the explicit module map JSON by ExplicitModuleMapParser
for both Swift (ExplicitSwiftModuleInputInfo) and Clang
(ExplicitClangModuleInputInfo) modules.
- Looked up in ModuleLibraryLevelRequest via
ASTContext::getExplicitModuleLibraryLevel(name, isClang), which
consults the appropriate map (Swift or Clang) based on module kind.
rdar://172693314
Assisted-By: Claude
The feature was added only to avoid a reverse-condfail
in the initial bring-up of noncopyable generics.
Nearly 2 years have passed since the last time I tried
to remove this old technical debt [1] and had to revert
it due to outdated build bots [2]. Hoping that won't be
a problem this time.
[1] 5b2f2cbfcf
[2] https://github.com/swiftlang/swift/pull/75267
resolves rdar://131560183
We need to start moving people over to using the version of
suppressed associated types that has the officially accepted
behavior according to SE-503, and that is via
`SuppressedAssociatedTypesWithDefaults`.
To allow for time to migrate to the new version, I'm introducing
the deprecation message as a warning for now.
This set of changes also moves most of the test suite over to using
the officially accepted version.
rdar://172231663
Previously, the `@_accessorBlock` disambiguation attribute was only
emitted for observed variables. But We need `@_accessorBlock`
disambiguation marker for simple stored properties with non-public
setters in `@frozen` types too.
rdar://171819084