@@ -913,8 +913,7 @@ static VarDecl *getPointeeProperty(VarDecl *&cache,
913
913
NominalTypeDecl *nominal = (ctx.*getNominal)();
914
914
if (!nominal) return nullptr ;
915
915
auto sig = nominal->getGenericSignature ();
916
- if (!sig) return nullptr ;
917
- if (sig->getGenericParams ().size () != 1 ) return nullptr ;
916
+ if (sig.getGenericParams ().size () != 1 ) return nullptr ;
918
917
919
918
// There must be a property named "pointee".
920
919
auto identifier = ctx.getIdentifier (" pointee" );
@@ -924,7 +923,7 @@ static VarDecl *getPointeeProperty(VarDecl *&cache,
924
923
// The property must have type T.
925
924
auto *property = dyn_cast<VarDecl>(results[0 ]);
926
925
if (!property) return nullptr ;
927
- if (!property->getInterfaceType ()->isEqual (sig-> getGenericParams ()[0 ]))
926
+ if (!property->getInterfaceType ()->isEqual (sig. getGenericParams ()[0 ]))
928
927
return nullptr ;
929
928
930
929
cache = property;
@@ -1776,8 +1775,8 @@ static AllocationArena getArena(GenericSignature genericSig) {
1776
1775
if (!genericSig)
1777
1776
return AllocationArena::Permanent;
1778
1777
1779
- if (genericSig-> hasTypeVariable ()) {
1780
- assert (false && " What's going on " );
1778
+ if (genericSig. hasTypeVariable ()) {
1779
+ assert (false && " Unsubstituted type variable leaked into generic signature " );
1781
1780
return AllocationArena::ConstraintSolver;
1782
1781
}
1783
1782
@@ -1844,13 +1843,13 @@ GenericSignatureBuilder *ASTContext::getOrCreateGenericSignatureBuilder(
1844
1843
reprocessedSig->print (llvm::errs ());
1845
1844
llvm::errs () << " \n " ;
1846
1845
1847
- if (sig-> getGenericParams ().size () ==
1848
- reprocessedSig-> getGenericParams ().size () &&
1849
- sig-> getRequirements ().size () ==
1850
- reprocessedSig-> getRequirements ().size ()) {
1851
- for (unsigned i : indices (sig-> getRequirements ())) {
1852
- auto sigReq = sig-> getRequirements ()[i];
1853
- auto reprocessedReq = reprocessedSig-> getRequirements ()[i];
1846
+ if (sig. getGenericParams ().size () ==
1847
+ reprocessedSig. getGenericParams ().size () &&
1848
+ sig. getRequirements ().size () ==
1849
+ reprocessedSig. getRequirements ().size ()) {
1850
+ for (unsigned i : indices (sig. getRequirements ())) {
1851
+ auto sigReq = sig. getRequirements ()[i];
1852
+ auto reprocessedReq = reprocessedSig. getRequirements ()[i];
1854
1853
if (sigReq.getKind () != reprocessedReq.getKind ()) {
1855
1854
llvm::errs () << " Requirement mismatch:\n " ;
1856
1855
llvm::errs () << " Original: " ;
@@ -1895,7 +1894,7 @@ GenericSignatureBuilder *ASTContext::getOrCreateGenericSignatureBuilder(
1895
1894
1896
1895
RequirementMachine *ASTContext::getOrCreateRequirementMachine (
1897
1896
CanGenericSignature sig) {
1898
- assert (!sig-> hasTypeVariable ());
1897
+ assert (!sig. hasTypeVariable ());
1899
1898
1900
1899
auto &rewriteCtx = getImpl ().TheRewriteContext ;
1901
1900
if (!rewriteCtx)
@@ -3608,12 +3607,12 @@ GenericTypeParamType *GenericTypeParamType::get(unsigned depth, unsigned index,
3608
3607
3609
3608
TypeArrayView<GenericTypeParamType>
3610
3609
GenericFunctionType::getGenericParams () const {
3611
- return Signature-> getGenericParams ();
3610
+ return Signature. getGenericParams ();
3612
3611
}
3613
3612
3614
3613
// / Retrieve the requirements of this polymorphic function type.
3615
3614
ArrayRef<Requirement> GenericFunctionType::getRequirements () const {
3616
- return Signature-> getRequirements ();
3615
+ return Signature. getRequirements ();
3617
3616
}
3618
3617
3619
3618
void SILFunctionType::Profile (
@@ -3747,7 +3746,7 @@ SILFunctionType::SILFunctionType(
3747
3746
" If all generic parameters are concrete, SILFunctionType should "
3748
3747
" not have a generic signature at all" );
3749
3748
3750
- for (auto gparam : genericSig-> getGenericParams ()) {
3749
+ for (auto gparam : genericSig. getGenericParams ()) {
3751
3750
(void )gparam;
3752
3751
assert (gparam->isCanonical () && " generic signature is not canonicalized" );
3753
3752
}
@@ -4123,7 +4122,7 @@ OpaqueTypeArchetypeType::get(OpaqueTypeDecl *Decl,
4123
4122
// Same-type-constrain the arguments in the outer signature to their
4124
4123
// replacements in the substitution map.
4125
4124
if (auto outerSig = Decl->getGenericSignature ()) {
4126
- for (auto outerParam : outerSig-> getGenericParams ()) {
4125
+ for (auto outerParam : outerSig. getGenericParams ()) {
4127
4126
auto boundType = Type (outerParam).subst (Substitutions);
4128
4127
newRequirements.push_back (
4129
4128
Requirement (RequirementKind::SameType, Type (outerParam), boundType));
@@ -4138,7 +4137,7 @@ OpaqueTypeArchetypeType::get(OpaqueTypeDecl *Decl,
4138
4137
(void )newRequirements;
4139
4138
# ifndef NDEBUG
4140
4139
for (auto reqt :
4141
- Decl->getOpaqueInterfaceGenericSignature ()-> getRequirements ()) {
4140
+ Decl->getOpaqueInterfaceGenericSignature (). getRequirements ()) {
4142
4141
auto reqtBase = reqt.getFirstType ()->getRootGenericParam ();
4143
4142
if (reqtBase->isEqual (Decl->getUnderlyingInterfaceType ())) {
4144
4143
assert (reqt.getKind () != RequirementKind::SameType
@@ -4261,7 +4260,7 @@ GenericEnvironment *OpenedArchetypeType::getGenericEnvironment() const {
4261
4260
// Create a generic environment to represent the opened type.
4262
4261
auto signature = ctx.getOpenedArchetypeSignature (Opened);
4263
4262
auto *env = GenericEnvironment::getIncomplete (signature);
4264
- env->addMapping (signature-> getGenericParams ()[ 0 ] , thisType);
4263
+ env->addMapping (signature. getGenericParams (). front (). getPointer () , thisType);
4265
4264
Environment = env;
4266
4265
4267
4266
return env;
@@ -4419,7 +4418,7 @@ GenericEnvironment *GenericEnvironment::getIncomplete(
4419
4418
auto &ctx = signature->getASTContext ();
4420
4419
4421
4420
// Allocate and construct the new environment.
4422
- unsigned numGenericParams = signature-> getGenericParams ().size ();
4421
+ unsigned numGenericParams = signature. getGenericParams ().size ();
4423
4422
size_t bytes = totalSizeToAlloc<Type>(numGenericParams);
4424
4423
void *mem = ctx.Allocate (bytes, alignof (GenericEnvironment));
4425
4424
return new (mem) GenericEnvironment (signature);
@@ -4913,7 +4912,7 @@ CanGenericSignature ASTContext::getOpenedArchetypeSignature(Type type) {
4913
4912
// The opened archetype signature for a protocol type is identical
4914
4913
// to the protocol's own canonical generic signature.
4915
4914
if (const auto protoTy = dyn_cast<ProtocolType>(existential)) {
4916
- return protoTy->getDecl ()->getGenericSignature ()-> getCanonicalSignature ();
4915
+ return protoTy->getDecl ()->getGenericSignature (). getCanonicalSignature ();
4917
4916
}
4918
4917
4919
4918
auto found = getImpl ().ExistentialSignatures .find (existential);
@@ -4982,9 +4981,9 @@ ASTContext::getOverrideGenericSignature(const ValueDecl *base,
4982
4981
unsigned derivedDepth = 0 ;
4983
4982
unsigned baseDepth = 0 ;
4984
4983
if (derivedClassSig)
4985
- derivedDepth = derivedClassSig-> getGenericParams ().back ()->getDepth () + 1 ;
4984
+ derivedDepth = derivedClassSig. getGenericParams ().back ()->getDepth () + 1 ;
4986
4985
if (const auto baseClassSig = baseClass->getGenericSignature ())
4987
- baseDepth = baseClassSig-> getGenericParams ().back ()->getDepth () + 1 ;
4986
+ baseDepth = baseClassSig. getGenericParams ().back ()->getDepth () + 1 ;
4988
4987
4989
4988
SmallVector<GenericTypeParamType *, 2 > addedGenericParams;
4990
4989
if (const auto *gpList = derived->getAsGenericContext ()->getGenericParams ()) {
@@ -5018,7 +5017,7 @@ ASTContext::getOverrideGenericSignature(const ValueDecl *base,
5018
5017
};
5019
5018
5020
5019
SmallVector<Requirement, 2 > addedRequirements;
5021
- for (auto reqt : baseGenericSig-> getRequirements ()) {
5020
+ for (auto reqt : baseGenericSig. getRequirements ()) {
5022
5021
if (auto substReqt = reqt.subst (substFn, lookupConformanceFn)) {
5023
5022
addedRequirements.push_back (*substReqt);
5024
5023
}
@@ -5116,7 +5115,7 @@ CanSILBoxType SILBoxType::get(ASTContext &C,
5116
5115
CanSILBoxType SILBoxType::get (CanType boxedType) {
5117
5116
auto &ctx = boxedType->getASTContext ();
5118
5117
auto singleGenericParamSignature = ctx.getSingleGenericParameterSignature ();
5119
- auto genericParam = singleGenericParamSignature-> getGenericParams ()[0 ];
5118
+ auto genericParam = singleGenericParamSignature. getGenericParams ()[0 ];
5120
5119
auto layout = SILLayout::get (ctx, singleGenericParamSignature,
5121
5120
SILField (CanType (genericParam),
5122
5121
/* mutable*/ true ));
@@ -5274,9 +5273,7 @@ AutoDiffDerivativeFunctionIdentifier *AutoDiffDerivativeFunctionIdentifier::get(
5274
5273
llvm::FoldingSetNodeID id;
5275
5274
id.AddInteger ((unsigned )kind);
5276
5275
id.AddPointer (parameterIndices);
5277
- CanGenericSignature derivativeCanGenSig;
5278
- if (derivativeGenericSignature)
5279
- derivativeCanGenSig = derivativeGenericSignature->getCanonicalSignature ();
5276
+ auto derivativeCanGenSig = derivativeGenericSignature.getCanonicalSignature ();
5280
5277
id.AddPointer (derivativeCanGenSig.getPointer ());
5281
5278
5282
5279
void *insertPos;
0 commit comments