Since getSpecifier() now kicks off a request instead of always
returning what was previously set, we can't pass a ParamSpecifier
to the ParamDecl constructor anymore. Instead, callers either
call setSpecifier() if the ParamDecl is synthesized, or they
rely on the request, which can compute the specifier in three
specific cases:
- Ordinary parsed parameters get their specifier from the TypeRepr.
- The 'self' parameter's specifier is based on the self access kind.
- Accessor parameters are either the 'newValue' parameter of a
setter, or a cloned subscript parameter.
For closure parameters with inferred types, we still end up
calling setSpecifier() twice, once to set the initial defalut
value and a second time when applying the solution in the
case that we inferred an 'inout' specifier. In practice this
should not be a big problem because expression type checking
walks the AST in a pre-determined order anyway.
By requestifying the raw value accessor and pushing the semantic check
into IRGen, we are now partially validating enums that are
synthesized by the clang importer and deserialization - something that
we were not doing before. The previous check would only skip
the auto-incrementer step when this was the case. We now also skip the
uniqueness check.
Resolves rdar://56037318
Structurally prevent a number of common anti-patterns involving generic
signatures by separating the interface into GenericSignature and the
implementation into GenericSignatureBase. In particular, this allows
the comparison operators to be deleted which forces callers to
canonicalize the signature or ask to compare pointers explicitly.
At one point in the past we probably needed to set this explicitly,
but now it seems to be handled for us or derived somewhere.
No functionality change.
And similar for importFunctionParamsAndReturnType and
importAccessorParamsAndReturnType. In all cases the return type isn't
a FunctionType, and there's also a ParameterList out-parameter.
No functionality change.
A typedef might get imported as an alias for a bridged type (String)
or for the original type (NSString), and a few parts of the importer
need to account for this. Simplify this logic based on how it's used
today.
Computing the interface type of a typealias used to push validation forward and recompute the interface type on the fly. This was fragile and inconsistent with the way interface types are computed in the rest of the decls. Separate these two notions, and plumb through explicit interface type computations with the same "computeType" idiom. This will better allow us to identify the places where we have to force an interface type computation.
Also remove access to the underlying type loc. It's now just a cache location the underlying type request will use. Push a type repr accessor to the places that need it, and push the underlying type accessor for everywhere else. Getting the structural type is still preferred for pre-validated computations.
This required the resetting of a number of places where we were - in many cases tacitly - asking the question "does the interface type exist". This enables the removal of validateDeclForNameLookup
Removes duplicated logic from the implementations of
FileUnit::lookupValue, and simplifies the interface to
ModuleDecl::lookupValue, where everyone was passing an empty
(non-filtering) access path anyway /except/ during actual lookup from
source code. No functionality change.
Explicitly apply the std::move as the signature of the callee is:
void swift::Evaluator::cacheOutput<swift::ExtendedNominalRequest, _>(const Request &, swift::NominalTypeDecl *&&)
The second formal parameter here is a `swift::ClassDecl` which is a
subclass of NominalTypeDecl, however, the cast will construct a
`swift::NominalTypeDecl *`. This is a lvalue and cannot be bound to a
r-value reference. Explicitly construct the r-value reference via
`std::move`.
This memoizes the result, which is fine for all callers; the only
exception is open existential types where each new open existential
now explicitly gets a unique generic environment, allocated by
calling GenericEnvironment::getIncomplete().
Since we started saving the nominal in the .swiftmodule, changing the other
call-sites in ClangImporter to save the value means that we can rely on
the typeRepr being non-null except when the syntax tree was ill-formed.
This avoids a re-entrant lookup while doing lazy member loading,
and eliminates a usage of LookupDirectFlags::IgnoreNewExtensions,
and the last usage of NominalTypeDecl::makeMemberVisible().