mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[NFC] Adopt TypeBase-isms for GenericSignature
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.
This commit is contained in:
@@ -356,7 +356,7 @@ synthesizeStubBody(AbstractFunctionDecl *fn, void *) {
|
||||
/*isTypeChecked=*/true };
|
||||
}
|
||||
|
||||
static std::tuple<GenericSignature *, GenericParamList *, SubstitutionMap>
|
||||
static std::tuple<GenericSignature, GenericParamList *, SubstitutionMap>
|
||||
configureGenericDesignatedInitOverride(ASTContext &ctx,
|
||||
ClassDecl *classDecl,
|
||||
Type superclassTy,
|
||||
@@ -367,7 +367,7 @@ configureGenericDesignatedInitOverride(ASTContext &ctx,
|
||||
auto subMap = superclassTy->getContextSubstitutionMap(
|
||||
moduleDecl, superclassDecl);
|
||||
|
||||
GenericSignature *genericSig;
|
||||
GenericSignature genericSig;
|
||||
|
||||
// Inheriting initializers that have their own generic parameters
|
||||
auto *genericParams = superclassCtor->getGenericParams();
|
||||
@@ -378,7 +378,7 @@ configureGenericDesignatedInitOverride(ASTContext &ctx,
|
||||
// but change the depth of the generic parameters to be one greater
|
||||
// than the depth of the subclass.
|
||||
unsigned depth = 0;
|
||||
if (auto *genericSig = classDecl->getGenericSignature())
|
||||
if (auto genericSig = classDecl->getGenericSignature())
|
||||
depth = genericSig->getGenericParams().back()->getDepth() + 1;
|
||||
|
||||
for (auto *param : genericParams->getParams()) {
|
||||
@@ -408,10 +408,10 @@ configureGenericDesignatedInitOverride(ASTContext &ctx,
|
||||
newParam->getDeclaredInterfaceType()->castTo<GenericTypeParamType>());
|
||||
}
|
||||
|
||||
auto *superclassSig = superclassCtor->getGenericSignature();
|
||||
auto superclassSig = superclassCtor->getGenericSignature();
|
||||
|
||||
unsigned superclassDepth = 0;
|
||||
if (auto *genericSig = superclassDecl->getGenericSignature())
|
||||
if (auto genericSig = superclassDecl->getGenericSignature())
|
||||
superclassDepth = genericSig->getGenericParams().back()->getDepth() + 1;
|
||||
|
||||
// We're going to be substituting the requirements of the base class
|
||||
@@ -448,11 +448,11 @@ configureGenericDesignatedInitOverride(ASTContext &ctx,
|
||||
genericSig = evaluateOrDefault(
|
||||
ctx.evaluator,
|
||||
AbstractGenericSignatureRequest{
|
||||
classDecl->getGenericSignature(),
|
||||
classDecl->getGenericSignature().getPointer(),
|
||||
std::move(newParamTypes),
|
||||
std::move(requirements)
|
||||
},
|
||||
nullptr);
|
||||
GenericSignature());
|
||||
} else {
|
||||
genericSig = classDecl->getGenericSignature();
|
||||
}
|
||||
@@ -636,7 +636,7 @@ createDesignatedInitOverride(ClassDecl *classDecl,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GenericSignature *genericSig;
|
||||
GenericSignature genericSig;
|
||||
GenericParamList *genericParams;
|
||||
SubstitutionMap subMap;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user