This ensures MemberImportVisibility diagnostics about missing imports of
CoreFoundation for `CGFloat.init(_:)` get a source location.
Resolves rdar://177380270.
The substitution is driven by a canonical type to mangled name table on ASTContext,
populated by exportability checking at the same site where the corresponding
diagnostics are suppressed. After this change, the module emitter and module
loader see hidden types differently: the emitter still sees the real types
defined in the bridging header, while the loader sees only a mangled name
wrapped in a HiddenType placeholder.
This is not supported for the same reason you can't have a noncopyable
variadic parameter, but the code was hard-coded to check for copyability
only.
Generalize this to apply the generic signature for Array via the
common code path, and add a custom note to explain why those requirements
are checked in the first place.
Cleaning this up also fixed some fuzzer crashes.
Reported on the forums:
https://forums.swift.org/t/variadic-escapable-arguments-crash-the-compiler/86727/2
Some new logic was added in 8bb3bf09fb but
it would overwrite a contextual type stored in the 'type' local variable
with an interface type.
Instead, let's only map the type into the generic environment after we
figure out what's going on with the property wrapper.
Add the module-format machinery that lets a Swift library record the
physical layout of hidden types (currently limited to C types imported via internal bridging header).
into binary modules, so downstream consumers can pull the layouts of these hidden types without
loading the internal dependency.
To test this, this change also added a frontend action to print hidden types' layouts
from both the module under compilation and all the modules being imported.
@_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
The diagnostic for an async sequence `for` loop missing a `try` got
accidentally dropped during the `for` loop desugaring rework. Restore
it here.
rdar://177062849
When checking conformances, if the witness to a protocol requirement is the
default witness for that requirement, ignore MemberImportVisibility
restrictions. A default witness is the witness that will be used at runtime for
a conformance to a resilient protocol when the conformance does not provide its
own witness. Default witnesses must belong to an unconstrained extension of the
protocol and be declared in the same module as that protocol. This exception is
necessary because otherwise evolving a protocol by adding a new requirement
with a default witness is potentially source breaking, even though it would not
be ABI breaking.
Resolves https://github.com/swiftlang/swift/issues/87227 and rdar://170348842.
HiddenType is a new TypeBase subclass that carries a mangled name
without leaking the actual type definition. It serves as a type-slot
placeholder for stored-property types that have been elided from a
serialized binary module, so that the client side can either
(1) resolve this mangled name to the real type if the client has access to the owning module, or
(2) use the mangled name as a key to query abstract layout information also serialized in the binary module.
As an example — a library with a hidden field of a bridging-imported type:
```
// Utility.h (internal bridging header)
// typedef struct { int value; } Wrapper;
public struct S {
private var w: Wrapper
public var weight: Double
}
In the serialized module, the client's view reconstructs as:
public struct S {
private var w: @_hidden("$sSo7Wrappera")
public var weight: Double
}
```
Adds a new DynamicMemberLookupSubscriptRequest type for evaluating and
caching the validity of a `SubscriptDecl`'s usage to fulfill a
`@dynamicMemberLookup` requirement for a specific usage.
Adds support for `SubscriptDecl`s to fulfill `@dynamicMemberLookup`
requirements if they have additional arguments after `dynamicMember:` so
long as those arguments have default values, or are variadic.
This allows exposing values like `#function`, `#fileID`, `#line`, etc.
to dynamic member lookup.
`SubscriptDecl` exposes eligibility for `@dynamicMemberLookup`
requirements directly, so the `TypeChecker` interface for these members
can be replaced.
`SubscriptDecl`s may get checked multiple times for eligibility in
fulfilling `@dynamicMemberLookup` requirements; since the checks are
non-trivial and the result doesn't change, this eligibility can be
cached in the decl's `Bits`.
A `let` binding declared `public`, `package`, or `open` participates in its module's ABI surface as a symbol — clients link against the declaration, not against its value, so the author is free to change the value in a future release. Folding such a reference in a literal expression would risk "baking" a module-private value into client code and remove the author's room to evolve the binding. Reject these references with a new diagnostic that reports the offending access level. `internal`, `fileprivate`, and `private` bindings continue to fold, as do Clang-imported constants.
The expression folder previously applied `APInt::lshr` for every `>>` regardless of signedness. For a negative signed operand this yields a large positive value and diverges from Swift runtime behavior, which performs an arithmetic right shift that preserves the sign bit.
Dispatch to `APInt::ashr` when the operand type is signed, and retain `APInt::lshr` for unsigned operands.