Skip to content

Commit 4944a76

Browse files
committed
AST: Add some handy assertions to GenericSignature
1 parent 4295625 commit 4944a76

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/AST/ASTContext.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3700,6 +3700,11 @@ GenericSignature *GenericSignature::get(ArrayRef<GenericTypeParamType *> params,
37003700
bool isKnownCanonical) {
37013701
assert(!params.empty());
37023702

3703+
#ifndef NDEBUG
3704+
for (auto req : requirements)
3705+
assert(req.getFirstType()->isTypeParameter());
3706+
#endif
3707+
37033708
// Check for an existing generic signature.
37043709
llvm::FoldingSetNodeID ID;
37053710
GenericSignature::Profile(ID, params, requirements);

lib/AST/GenericSignature.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,5 +487,7 @@ CanType GenericSignature::getCanonicalTypeInContext(Type type, ModuleDecl &mod)
487487
}
488488
});
489489

490-
return type->getCanonicalType();
490+
auto result = type->getCanonicalType();
491+
assert(isCanonicalTypeInContext(result, mod));
492+
return result;
491493
}

0 commit comments

Comments
 (0)