| 1190 | } |
| 1191 | |
| 1192 | void BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType) |
| 1193 | { |
| 1194 | if ((populateType == BfPopulateType_Declaration) && (resolvedTypeRef->mDefineState >= BfTypeDefineState_Declared)) |
| 1195 | return; |
| 1196 | |
| 1197 | if ((resolvedTypeRef->mRebuildFlags & BfTypeRebuildFlag_PendingGenericArgDep) != 0) |
| 1198 | { |
| 1199 | BfLogSysM("PopulateType handling BfTypeRebuildFlag_PendingGenericArgDep for type %p\n", resolvedTypeRef); |
| 1200 | // Reinit dependencies |
| 1201 | resolvedTypeRef->mRebuildFlags = (BfTypeRebuildFlags)(resolvedTypeRef->mRebuildFlags & ~BfTypeRebuildFlag_PendingGenericArgDep); |
| 1202 | DoPopulateType_SetGenericDependencies(resolvedTypeRef->ToTypeInstance()); |
| 1203 | } |
| 1204 | |
| 1205 | // Are we "demanding" to reify a type that is currently resolve-only? |
| 1206 | if ((mIsReified) && (populateType >= BfPopulateType_Declaration)) |
| 1207 | { |
| 1208 | if (resolvedTypeRef->IsTypeInstance()) |
| 1209 | { |
| 1210 | auto typeModule = resolvedTypeRef->GetModule(); |
| 1211 | if ((typeModule != NULL) && (typeModule->mIsSpecialModule)) |
| 1212 | { |
| 1213 | auto typeInst = resolvedTypeRef->ToTypeInstance(); |
| 1214 | if (!typeInst->mIsReified) |
| 1215 | { |
| 1216 | BfLogSysM("Reifying type %p in scratch module in PopulateType\n", resolvedTypeRef); |
| 1217 | |
| 1218 | // It's important for unspecialized types to be in the correct module -- |
| 1219 | // when we process their methods, new types will be determined as |
| 1220 | // resolve-only or reified based on the module the unresolved type is in |
| 1221 | BF_ASSERT(typeInst->mModule == mContext->mUnreifiedModule); |
| 1222 | typeInst->mIsReified = true; |
| 1223 | typeInst->mModule = mContext->mScratchModule; |
| 1224 | |
| 1225 | // Why did we need to do this at all? Why is just marking the type as reified not enough? |
| 1226 | // This causes issues where we may delete a method instance that is currently being used as the generic bindings for |
| 1227 | // a method of a specialized generic type |
| 1228 | // if (typeInst->IsOnDemand()) |
| 1229 | // { |
| 1230 | // RebuildMethods(typeInst); |
| 1231 | // } |
| 1232 | // else |
| 1233 | // mContext->RebuildType(typeInst, false, false); |
| 1234 | |
| 1235 | if (typeInst->mGenericTypeInfo != NULL) |
| 1236 | { |
| 1237 | for (auto genericArg : typeInst->mGenericTypeInfo->mTypeGenericArguments) |
| 1238 | { |
| 1239 | if (!genericArg->IsReified()) |
| 1240 | PopulateType(genericArg, BfPopulateType_Declaration); |
| 1241 | } |
| 1242 | } |
| 1243 | } |
| 1244 | } |
| 1245 | else |
| 1246 | { |
| 1247 | if ((typeModule != NULL) && (!typeModule->mIsReified) && (!typeModule->mReifyQueued)) |
| 1248 | { |
| 1249 | bool canFastReify = false; |
no test coverage detected