Skip to content

Commit f5545bb

Browse files
committed
AST: Relax a GenericSignature assertion
A type in a same-type requirement can have a non-canonical type if its parent is a concrete type.
1 parent c79a89b commit f5545bb

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/AST/GenericSignature.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,23 +1611,25 @@ void GenericSignature::verify(ArrayRef<Requirement> reqts) const {
16111611
break;
16121612

16131613
case RequirementKind::SameType: {
1614-
auto isCanonicalAnchor = [&](Type type) {
1615-
if (auto *dmt = type->getAs<DependentMemberType>())
1616-
return canSig->isCanonicalTypeInContext(dmt->getBase());
1614+
auto hasCanonicalOrConcreteParent = [&](Type type) {
1615+
if (auto *dmt = type->getAs<DependentMemberType>()) {
1616+
return (canSig->isCanonicalTypeInContext(dmt->getBase()) ||
1617+
canSig->isConcreteType(dmt->getBase()));
1618+
}
16171619
return type->is<GenericTypeParamType>();
16181620
};
16191621

16201622
auto firstType = reqt.getFirstType();
16211623
auto secondType = reqt.getSecondType();
1622-
if (!isCanonicalAnchor(firstType)) {
1624+
if (!hasCanonicalOrConcreteParent(firstType)) {
16231625
llvm::errs() << "Left hand side does not have a canonical parent: ";
16241626
reqt.dump(llvm::errs());
16251627
llvm::errs() << "\n";
16261628
abort();
16271629
}
16281630

16291631
if (reqt.getSecondType()->isTypeParameter()) {
1630-
if (!isCanonicalAnchor(secondType)) {
1632+
if (!hasCanonicalOrConcreteParent(secondType)) {
16311633
llvm::errs() << "Right hand side does not have a canonical parent: ";
16321634
reqt.dump(llvm::errs());
16331635
llvm::errs() << "\n";

0 commit comments

Comments
 (0)