File tree Expand file tree Collapse file tree 4 files changed +22
-3
lines changed Expand file tree Collapse file tree 4 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -147,7 +147,8 @@ class alignas(1 << TypeAlignInBits) GenericSignature final
147
147
// / requirements, first canonicalizing the types.
148
148
static CanGenericSignature getCanonical (
149
149
ArrayRef<GenericTypeParamType *> params,
150
- ArrayRef<Requirement> requirements);
150
+ ArrayRef<Requirement> requirements,
151
+ bool skipValidation = false );
151
152
152
153
// / Retrieve the generic parameters.
153
154
ArrayRef<GenericTypeParamType *> getGenericParams () const {
Original file line number Diff line number Diff line change @@ -150,7 +150,8 @@ static unsigned getRequirementKindOrder(RequirementKind kind) {
150
150
151
151
CanGenericSignature GenericSignature::getCanonical (
152
152
ArrayRef<GenericTypeParamType *> params,
153
- ArrayRef<Requirement> requirements) {
153
+ ArrayRef<Requirement> requirements,
154
+ bool skipValidation) {
154
155
// Canonicalize the parameters and requirements.
155
156
SmallVector<GenericTypeParamType*, 8 > canonicalParams;
156
157
canonicalParams.reserve (params.size ());
@@ -172,10 +173,14 @@ CanGenericSignature GenericSignature::getCanonical(
172
173
reqt.getLayoutConstraint ()));
173
174
}
174
175
176
+ (void )skipValidation;
175
177
auto canSig = get (canonicalParams, canonicalRequirements,
176
178
/* isKnownCanonical=*/ true );
177
179
178
180
#ifndef NDEBUG
181
+ if (skipValidation)
182
+ return CanGenericSignature (canSig);
183
+
179
184
PrettyStackTraceGenericSignature debugStack (" canonicalizing" , canSig);
180
185
181
186
// Check that the signature is canonical.
Original file line number Diff line number Diff line change @@ -3026,6 +3026,12 @@ ResolvedType GenericSignatureBuilder::maybeResolveEquivalenceClass(
3026
3026
TypeDecl *nestedTypeDecl;
3027
3027
SmallVector<TypeDecl *, 4 > concreteDecls;
3028
3028
if (auto assocType = depMemTy->getAssocType ()) {
3029
+ // Check whether this associated type references a protocol to which
3030
+ // the base conforms. If not, it's unresolved.
3031
+ if (baseEquivClass->conformsTo .find (assocType->getProtocol ())
3032
+ == baseEquivClass->conformsTo .end ())
3033
+ return ResolvedType::forUnresolved (baseEquivClass);
3034
+
3029
3035
nestedTypeDecl = assocType;
3030
3036
} else {
3031
3037
nestedTypeDecl =
Original file line number Diff line number Diff line change @@ -4885,8 +4885,15 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
4885
4885
llvm::errs () << " Requirement signature: " ;
4886
4886
requirementsSig->print (llvm::errs ());
4887
4887
llvm::errs () << " \n " ;
4888
+
4889
+ // Note: One cannot canonicalize a requirement signature, because
4890
+ // requirement signatures are necessarily missing requirements.
4888
4891
llvm::errs () << " Canonical requirement signature: " ;
4889
- requirementsSig->getCanonicalSignature ()->print (llvm::errs ());
4892
+ auto canRequirementSig =
4893
+ GenericSignature::getCanonical (requirementsSig->getGenericParams (),
4894
+ requirementsSig->getRequirements (),
4895
+ /* skipValidation=*/ true );
4896
+ canRequirementSig->print (llvm::errs ());
4890
4897
llvm::errs () << " \n " ;
4891
4898
}
4892
4899
}
You can’t perform that action at this time.
0 commit comments