Skip to content

Commit f902ce1

Browse files
committed
Sema: Don't break inheritance cycles in checkCircularity()
It's too late to do it here, because this method is only called as part of typeCheckDecl() and not validateDecl().
1 parent 00b3ce1 commit f902ce1

File tree

2 files changed

+4
-24
lines changed

2 files changed

+4
-24
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -603,23 +603,6 @@ static ArrayRef<EnumDecl *> getInheritedForCycleCheck(TypeChecker &tc,
603603
return { };
604604
}
605605

606-
// Break the inheritance cycle for a protocol by removing all inherited
607-
// protocols.
608-
//
609-
// FIXME: Just remove the problematic inheritance?
610-
static void breakInheritanceCycle(ProtocolDecl *proto) {
611-
}
612-
613-
/// Break the inheritance cycle for a class by removing its superclass.
614-
static void breakInheritanceCycle(ClassDecl *classDecl) {
615-
classDecl->setSuperclass(Type());
616-
}
617-
618-
/// Break the inheritance cycle for an enum by removing its raw type.
619-
static void breakInheritanceCycle(EnumDecl *enumDecl) {
620-
enumDecl->setRawType(Type());
621-
}
622-
623606
/// Check for circular inheritance.
624607
template<typename T>
625608
static void checkCircularity(TypeChecker &tc, T *decl,
@@ -649,9 +632,6 @@ static void checkCircularity(TypeChecker &tc, T *decl,
649632
circularDiag,
650633
path.back()->getName());
651634

652-
decl->setInvalid();
653-
decl->setInterfaceType(ErrorType::get(tc.Context));
654-
breakInheritanceCycle(decl);
655635
break;
656636
}
657637

@@ -663,10 +643,6 @@ static void checkCircularity(TypeChecker &tc, T *decl,
663643
declKind, (*i)->getName());
664644
}
665645

666-
// Set this declaration as invalid, then break the cycle somehow.
667-
decl->setInvalid();
668-
decl->setInterfaceType(ErrorType::get(tc.Context));
669-
breakInheritanceCycle(decl);
670646
break;
671647
}
672648

lib/Sema/TypeCheckDeclOverride.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,10 @@ static bool diagnoseOverrideForAvailability(ValueDecl *override,
13451345

13461346
static bool recordOverride(TypeChecker &TC, ValueDecl *override,
13471347
ValueDecl *base, bool isKnownObjC) {
1348+
// This can happen with circular inheritance.
1349+
if (override == base)
1350+
return true;
1351+
13481352
ASTContext &ctx = override->getASTContext();
13491353
auto &diags = ctx.Diags;
13501354

0 commit comments

Comments
 (0)