The last step in building a generic signature is to sort the requirements.
Requirements are sorted by comparing their subject types. If two
requirements have the same subject type, which can only happen with
conformance requirements, we break the tie by comparing protocol
declarations.
We compare protocol declarations using TypeDecl::compare(), which is a
shortlex order on the components of the fully qualified name of a
protocol (eg, Swift.Sequence, etc.)
While this order is part of the ABI, it has not been updated over the
years for several important changes:
- It did not handle module aliases; if we import a module via an
alias, we should use the real module name to compare protocols, and
not the aliased name. This produced inconsistent results if the
same module was imported under different names, which can happen
with module interface files that use module aliases.
- It did not handle the -module-abi-name flag. Changing the ABI name
of a module changes how we mangle protocol names, and the order
should match the mangling.
This change fixes the first case only. The second requires more
careful staging, because of _Concurrency and CompilerSwiftSyntax.
Fixes rdar://147441890.
ABI-only declarations now inherit access control modifiers like `public` or `private(set)`, as well as `@usableFromInline` and `@_spi`, from their API counterpart. This means these attributes and modifiers don’t need to be specified in an `@abi` attribute.
Very few tests because we aren’t yet enforcing the absence of these attributes.
ABI-only declarations now query their API counterpart for things like `isObjC()`, their ObjC name, dynamic status, etc. This means that `@objc` and friends can simply be omitted from an `@abi` attribute.
No tests in this commit since attribute checking hasn’t landed yet.
The module name changes the symbol mangling, and also causes
TBDGen to emit linker directives. To separate out these two
behaviors, introduce a terrible hack. If the module name
contains a semicolon (`;`), the part before the semicolon
is the module name for mangling, and the part after the
semicolon is the module name for linker directives.
If there is no semicolon, both module names are identical,
and the behavior is the same as before.
This fixes a compiler bug that got exposed by f11abac652.
If a C++ type is declared in a nested Clang submodule, Swift was emitting errors that look like:
```
Type alias 'string' is not available due to missing import of defining module 'fwd’
```
rdar://146899125
Instead of using the `isolated P` syntax, switch to specifying the
global actor type directly, e.g.,
class MyClass: @MainActor MyProto { ... }
No functionality change at this point
Introduce a constructor that takes an `llvm::VersionTuple` directly, instead of
needing to spell out `VersionRange::allGTE(<tuple>)` which is unnecessarily
verbose.
To pave the way for the new experimental feature which will operate on '@const' attribute and expand the scope of what's currently handled by '_const' without breaking compatibility, for now.
Allow a conformance to be "isolated", meaning that it stays in the same
isolation domain as the conforming type. Only allow this for
global-actor-isolated types.
When a conformance is isolated, a nonisolated requirement can be
witnessed by a declaration with the same global actor isolation as the
enclosing type.
If an enum comes from a different module that has `ExtensibleEnums`
feature enabled, unless it requires either `@unknown default:` or
`@frozen` because it is allowed to introduce new cases in the future
versions of the module.
* Collect flag in `ParamDecl::setTypeRepr()`.
* [ASTGen] Separate `BridgedParamDecl.setTypeRepr(_:)` from
`BridgedParamDecl.createParsed(_:)` aligning with C++ API. The majority
of the creations don't set the typerepr.
* Update `ParamSpecifierRequest::evaluate` to handle non-implicit
`ParamDecl` without `TypeRepr` (i.e. untyped closure parameter), instead
of `setSpecifier(::Default)` manually in Parse.
Interop is injecting escapability annotations for the STL and doing a
limited inference for aggregates. Let's reuse the same facilities in the
AST when we calculate the safety of the foreign types.
An `AvailableAttr` written in source with an unrecognized availability domain
is now only marked invalid after type-checking the attribute. This resulted in a
regression where `CaseIterable` synthesis was blocked incorrectly under the
following very narrow circumstances:
1. Every `@available` attribute on the elements of the enum is invalid.
2. The module is being emitted and lazy type-checking is enabled.
3. The enum is public and the only top-level declaration in the file.
Type-checking the attribute was delayed just enough that it would not be
considered invalid by the type the `CaseIterable` conformance was being
synthesized, resulting in a spurious error.
There were zero tests exercising `CaseIterable` synthesis for enums with
elements that have availability requirements, so I added some.
Resolves rdar://144897917.
* Instead of hoisting VarDecl in the bridging functions, do it in
ASTGen.
* Introduce `Decl::forEachDeclToHoist` to handle VarDecls in
PatternBindingDecl, and EnumElementDecl in EnumCaseDecl.
* Intorduce `withBridgedSwiftClosure(closure:call:)` as a callback
mechanism between Swift and C++
* In `generate(sourceFile:)`, instead of using `generate(codeBlockItem:)`
handle `CodeBlockItemSyntax.Item` manually to handle `TLCD` wrapping
and `VarDecl` hoisting.
* Make `generate(variableDecl:)` handle TLCD correctly.