mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Lift Requirement and Parameter Accessors up to GenericSignature
Start treating the null {Can}GenericSignature as a regular signature
with no requirements and no parameters. This not only makes for a much
safer abstraction, but allows us to simplify a lot of the clients of
GenericSignature that would previously have to check for null before
using the abstraction.
This commit is contained in:
@@ -1354,7 +1354,7 @@ void Serializer::writeASTBlockEntity(GenericSignature sig) {
|
||||
// have to encode them manually because one of them has a declaration with
|
||||
// module context (which can happen in SIL).
|
||||
bool mustEncodeParamsManually =
|
||||
llvm::any_of(sig->getGenericParams(),
|
||||
llvm::any_of(sig.getGenericParams(),
|
||||
[](const GenericTypeParamType *paramTy) {
|
||||
auto *decl = paramTy->getDecl();
|
||||
return decl && decl->getDeclContext()->isModuleScopeContext();
|
||||
@@ -1363,7 +1363,7 @@ void Serializer::writeASTBlockEntity(GenericSignature sig) {
|
||||
if (!mustEncodeParamsManually) {
|
||||
// Record the generic parameters.
|
||||
SmallVector<uint64_t, 4> rawParamIDs;
|
||||
for (auto *paramTy : sig->getGenericParams()) {
|
||||
for (auto *paramTy : sig.getGenericParams()) {
|
||||
rawParamIDs.push_back(addTypeRef(paramTy));
|
||||
}
|
||||
|
||||
@@ -1373,7 +1373,7 @@ void Serializer::writeASTBlockEntity(GenericSignature sig) {
|
||||
} else {
|
||||
// Record the generic parameters.
|
||||
SmallVector<uint64_t, 4> rawParamIDs;
|
||||
for (auto *paramTy : sig->getGenericParams()) {
|
||||
for (auto *paramTy : sig.getGenericParams()) {
|
||||
auto *decl = paramTy->getDecl();
|
||||
|
||||
// For a full environment, add the name and canonicalize the param type.
|
||||
@@ -1389,7 +1389,7 @@ void Serializer::writeASTBlockEntity(GenericSignature sig) {
|
||||
rawParamIDs);
|
||||
}
|
||||
|
||||
writeGenericRequirements(sig->getRequirements(), DeclTypeAbbrCodes);
|
||||
writeGenericRequirements(sig.getRequirements(), DeclTypeAbbrCodes);
|
||||
}
|
||||
|
||||
void Serializer::writeASTBlockEntity(const SubstitutionMap substitutions) {
|
||||
|
||||
Reference in New Issue
Block a user