@@ -1607,9 +1607,22 @@ namespace {
1607
1607
return E->getType ();
1608
1608
1609
1609
// 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;
1613
1626
}
1614
1627
1615
1628
Type
@@ -3298,39 +3311,6 @@ namespace {
3298
3311
return resultType;
3299
3312
}
3300
3313
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
-
3334
3314
Type visitRebindSelfInConstructorExpr (RebindSelfInConstructorExpr *expr) {
3335
3315
// The result is void.
3336
3316
return TupleType::getEmpty (CS.getASTContext ());
0 commit comments