mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
NFC: Add GenericSignature::getCanonicalSignature. (#29105)
Motivation: `GenericSignatureImpl::getCanonicalSignature` crashes for `GenericSignature` with underlying `nullptr`. This led to verbose workarounds when computing `CanGenericSignature` from `GenericSignature`. Solution: `GenericSignature::getCanonicalSignature` is a wrapper around `GenericSignatureImpl::getCanonicalSignature` that returns the canonical signature, or `nullptr` if the underlying pointer is `nullptr`. Rewrite all verbose workarounds using `GenericSignature::getCanonicalSignature`.
This commit is contained in:
@@ -327,7 +327,7 @@ namespace {
|
||||
void addGenericParameters() {
|
||||
GenericSignature sig = asImpl().getGenericSignature();
|
||||
assert(sig);
|
||||
auto canSig = sig->getCanonicalSignature();
|
||||
auto canSig = sig.getCanonicalSignature();
|
||||
|
||||
canSig->forEachParam([&](GenericTypeParamType *param, bool canonical) {
|
||||
// Currently, there are only type parameters. The parameter is a key
|
||||
@@ -1688,10 +1688,8 @@ namespace {
|
||||
auto underlyingType = Type(O->getUnderlyingInterfaceType())
|
||||
.subst(*O->getUnderlyingTypeSubstitutions())
|
||||
->getCanonicalType(sig);
|
||||
|
||||
auto contextSig = O->getGenericSignature()
|
||||
? O->getGenericSignature()->getCanonicalSignature()
|
||||
: CanGenericSignature();
|
||||
|
||||
auto contextSig = O->getGenericSignature().getCanonicalSignature();
|
||||
|
||||
B.addRelativeAddress(IGM.getTypeRef(underlyingType, contextSig,
|
||||
MangledTypeRefRole::Metadata).first);
|
||||
|
||||
Reference in New Issue
Block a user