@@ -1607,9 +1607,22 @@ namespace {
16071607 return E->getType ();
16081608
16091609 // Resolve the super type of 'self'.
1610- return getSuperType (E->getSelf (), E->getLoc (),
1611- diag::super_invalid_context,
1612- diag::super_no_superclass);
1610+ auto *selfDecl = E->getSelf ();
1611+
1612+ DeclContext *typeContext = selfDecl->getDeclContext ()->getParent ();
1613+ assert (typeContext);
1614+
1615+ auto selfTy =
1616+ CS.DC ->mapTypeIntoContext (typeContext->getDeclaredInterfaceType ());
1617+ auto superclassTy = selfTy->getSuperclass ();
1618+
1619+ if (!superclassTy)
1620+ return Type ();
1621+
1622+ if (selfDecl->getInterfaceType ()->is <MetatypeType>())
1623+ superclassTy = MetatypeType::get (superclassTy);
1624+
1625+ return superclassTy;
16131626 }
16141627
16151628 Type
@@ -3298,39 +3311,6 @@ namespace {
32983311 return resultType;
32993312 }
33003313
3301- Type getSuperType (VarDecl *selfDecl, SourceLoc diagLoc,
3302- Diag<> diag_not_in_class,
3303- Diag<bool , const ClassDecl *> diag_no_superclass) {
3304- DeclContext *typeContext = selfDecl->getDeclContext ()->getParent ();
3305- assert (typeContext && " constructor without parent context?!" );
3306-
3307- auto &de = CS.getASTContext ().Diags ;
3308- ClassDecl *classDecl = typeContext->getSelfClassDecl ();
3309- if (!classDecl) {
3310- de.diagnose (diagLoc, diag_not_in_class);
3311- return Type ();
3312- }
3313- if (!classDecl->hasSuperclass ()) {
3314- de.diagnose (
3315- diagLoc, diag_no_superclass,
3316- /* isExtension*/ isa<ExtensionDecl>(typeContext->getAsDecl ()),
3317- classDecl);
3318- return Type ();
3319- }
3320-
3321- auto selfTy = CS.DC ->mapTypeIntoContext (
3322- typeContext->getDeclaredInterfaceType ());
3323- auto superclassTy = selfTy->getSuperclass ();
3324-
3325- if (!superclassTy)
3326- return Type ();
3327-
3328- if (selfDecl->getInterfaceType ()->is <MetatypeType>())
3329- superclassTy = MetatypeType::get (superclassTy);
3330-
3331- return superclassTy;
3332- }
3333-
33343314 Type visitRebindSelfInConstructorExpr (RebindSelfInConstructorExpr *expr) {
33353315 // The result is void.
33363316 return TupleType::getEmpty (CS.getASTContext ());
0 commit comments