@@ -153,16 +153,19 @@ static bool specializeVTablesOfSuperclasses(SILModule &module,
153153SILVTable *swift::specializeVTableForType (SILType classTy, SILModule &module ,
154154 SILTransform *transform) {
155155 CanType astType = classTy.getASTType ();
156- BoundGenericClassType *genClassTy = dyn_cast<BoundGenericClassType>(astType);
157- if (!genClassTy) return nullptr ;
156+ if (!astType->isSpecialized ())
157+ return nullptr ;
158+ NominalOrBoundGenericNominalType *genClassTy = dyn_cast<NominalOrBoundGenericNominalType>(astType);
159+ ClassDecl *classDecl = astType->getClassOrBoundGenericClass ();
160+ if (!classDecl)
161+ return nullptr ;
158162
159163 if (module .lookUpSpecializedVTable (classTy)) return nullptr ;
160164
161165 LLVM_DEBUG (llvm::errs () << " specializeVTableFor "
162- << genClassTy-> getDecl () ->getName () << ' '
166+ << classDecl ->getName () << ' '
163167 << genClassTy->getString () << ' \n ' );
164168
165- ClassDecl *classDecl = genClassTy->getDecl ();
166169 SILVTable *origVtable = module .lookUpVTable (classDecl);
167170 if (!origVtable) {
168171 // This cannot occur in regular builds - only if built without wmo, which
@@ -244,8 +247,8 @@ bool swift::specializeClassMethodInst(ClassMethodInst *cm) {
244247 SILValue instance = cm->getOperand ();
245248 SILType classTy = instance->getType ();
246249 CanType astType = classTy.getASTType ();
247- BoundGenericClassType *genClassTy = dyn_cast<BoundGenericClassType>( astType);
248- if (!genClassTy) return false ;
250+ if (! astType-> isSpecialized ())
251+ return false ;
249252
250253 SubstitutionMap subs = astType->getContextSubstitutionMap ();
251254
0 commit comments