@@ -523,14 +523,20 @@ Type TypeBase::getSuperclassForDecl(const ClassDecl *baseClass,
523
523
t = t->getSuperclass (useArchetypes);
524
524
}
525
525
526
- #ifndef NDEBUG
527
- auto *currentClass = getConcreteTypeForSuperclassTraversing (this )
528
- ->getClassOrBoundGenericClass ();
529
- assert (baseClass->isSuperclassOf (currentClass) &&
530
- " no inheritance relationship between given classes" );
531
- #endif
532
-
533
- return ErrorType::get (this );
526
+ if (CONDITIONAL_ASSERT_enabled ()) {
527
+ auto *currentClass = getConcreteTypeForSuperclassTraversing (this )
528
+ ->getClassOrBoundGenericClass ();
529
+ ASSERT (baseClass->isSuperclassOf (currentClass) &&
530
+ " no inheritance relationship between given classes" );
531
+ }
532
+
533
+ // We can end up here if the AST is invalid, because then
534
+ // getSuperclassDecl() might resolve to a decl, and yet
535
+ // getSuperclass() is just an ErrorType. Make sure we still
536
+ // return a nominal type as the result though, and not an
537
+ // ErrorType, because that's what callers expect.
538
+ return baseClass->getDeclaredInterfaceType ()
539
+ .subst (SubstitutionMap ())->getCanonicalType ();
534
540
}
535
541
536
542
SubstitutionMap TypeBase::getContextSubstitutionMap () {
@@ -546,7 +552,7 @@ SubstitutionMap TypeBase::getContextSubstitutionMap() {
546
552
547
553
Type baseTy (this );
548
554
549
- assert (!baseTy->hasLValueType () &&
555
+ assert (!baseTy->is <LValueType> () &&
550
556
!baseTy->is <AnyMetatypeType>() &&
551
557
!baseTy->is <ErrorType>());
552
558
@@ -628,7 +634,7 @@ TypeBase::getContextSubstitutions(const DeclContext *dc,
628
634
assert (dc->isTypeContext ());
629
635
Type baseTy (this );
630
636
631
- assert (!baseTy->hasLValueType () &&
637
+ assert (!baseTy->is <LValueType> () &&
632
638
!baseTy->is <AnyMetatypeType>() &&
633
639
!baseTy->is <ErrorType>());
634
640
0 commit comments