@@ -7452,27 +7452,39 @@ bool SILParserState::parseSILVTable(Parser &P) {
74527452 nullptr , nullptr , VTableState, M))
74537453 return true ;
74547454
7455- // Parse the class name.
7456- Identifier Name;
7457- SourceLoc Loc;
7458- if (VTableState.parseSILIdentifier (Name, Loc,
7459- diag::expected_sil_value_name))
7460- return true ;
74617455
7462- // Find the class decl.
7463- llvm::PointerUnion<ValueDecl*, ModuleDecl *> Res =
7464- lookupTopDecl (P, Name, /* typeLookup= */ true );
7465- assert (Res. is <ValueDecl*>() && " Class look-up should return a Decl " );
7466- ValueDecl *VD = Res. get <ValueDecl*>() ;
7467- if (!VD) {
7468- P. diagnose (Loc, diag::sil_vtable_class_not_found, Name);
7469- return true ;
7470- }
7456+ ClassDecl *theClass = nullptr ;
7457+ SILType specializedClassTy;
7458+ if (P. Tok . isNot (tok::sil_dollar)) {
7459+ // Parse the class name.
7460+ Identifier Name ;
7461+ SourceLoc Loc;
7462+ if (VTableState. parseSILIdentifier (Name, Loc,
7463+ diag::expected_sil_value_name))
7464+ return true ;
74717465
7472- auto *theClass = dyn_cast<ClassDecl>(VD);
7473- if (!theClass) {
7474- P.diagnose (Loc, diag::sil_vtable_class_not_found, Name);
7475- return true ;
7466+ // Find the class decl.
7467+ llvm::PointerUnion<ValueDecl*, ModuleDecl *> Res =
7468+ lookupTopDecl (P, Name, /* typeLookup=*/ true );
7469+ assert (Res.is <ValueDecl*>() && " Class look-up should return a Decl" );
7470+ ValueDecl *VD = Res.get <ValueDecl*>();
7471+ if (!VD) {
7472+ P.diagnose (Loc, diag::sil_vtable_class_not_found, Name);
7473+ return true ;
7474+ }
7475+
7476+ theClass = dyn_cast<ClassDecl>(VD);
7477+ if (!theClass) {
7478+ P.diagnose (Loc, diag::sil_vtable_class_not_found, Name);
7479+ return true ;
7480+ }
7481+ } else {
7482+ if (SILParser (P).parseSILType (specializedClassTy))
7483+ return true ;
7484+ theClass = specializedClassTy.getClassOrBoundGenericClass ();
7485+ if (!theClass) {
7486+ return true ;
7487+ }
74767488 }
74777489
74787490 SourceLoc LBraceLoc = P.Tok .getLoc ();
@@ -7540,7 +7552,7 @@ bool SILParserState::parseSILVTable(Parser &P) {
75407552 P.parseMatchingToken (tok::r_brace, RBraceLoc, diag::expected_sil_rbrace,
75417553 LBraceLoc);
75427554
7543- SILVTable::create (M, theClass, Serialized, vtableEntries);
7555+ SILVTable::create (M, theClass, specializedClassTy, Serialized, vtableEntries);
75447556 return false ;
75457557}
75467558
0 commit comments