diff --git a/IDEHelper/Compiler/BfModuleTypeUtils.cpp b/IDEHelper/Compiler/BfModuleTypeUtils.cpp index 1452ff19..13aed904 100644 --- a/IDEHelper/Compiler/BfModuleTypeUtils.cpp +++ b/IDEHelper/Compiler/BfModuleTypeUtils.cpp @@ -2096,42 +2096,45 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy typeInstance->mInstSize = std::max(0, typeInstance->mInstSize); typeInstance->mInstAlign = std::max(0, typeInstance->mInstAlign); - if ((typeInstance->mCustomAttributes == NULL) && (typeDef->mTypeDeclaration != NULL) && (typeDef->mTypeDeclaration->mAttributes != NULL)) + if (!typeInstance->IsBoxed()) { - BfAttributeTargets attrTarget; - if ((typeDef->mIsDelegate) || (typeDef->mIsFunction)) - attrTarget = BfAttributeTargets_Delegate; - else if (typeInstance->IsEnum()) - attrTarget = BfAttributeTargets_Enum; - else if (typeInstance->IsInterface()) - attrTarget = BfAttributeTargets_Interface; - else if (typeInstance->IsStruct()) - attrTarget = BfAttributeTargets_Struct; - else - attrTarget = BfAttributeTargets_Class; - if (!typeInstance->mTypeFailed) + if ((typeInstance->mCustomAttributes == NULL) && (typeDef->mTypeDeclaration != NULL) && (typeDef->mTypeDeclaration->mAttributes != NULL)) { - // This allows us to avoid reentrancy when checking for inner types - SetAndRestoreValue prevSkipTypeProtectionChecks(typeInstance->mSkipTypeProtectionChecks, true); - if (typeDef->mIsCombinedPartial) - { - for (auto partialTypeDef : typeDef->mPartials) - { - if (partialTypeDef->mTypeDeclaration->mAttributes == NULL) - continue; - BfTypeState typeState; - typeState.mPrevState = mContext->mCurTypeState; - typeState.mCurTypeDef = partialTypeDef; - typeState.mTypeInstance = typeInstance; - SetAndRestoreValue prevTypeState(mContext->mCurTypeState, &typeState); - - if (typeInstance->mCustomAttributes == NULL) - typeInstance->mCustomAttributes = new BfCustomAttributes(); - GetCustomAttributes(typeInstance->mCustomAttributes, partialTypeDef->mTypeDeclaration->mAttributes, attrTarget); - } - } + BfAttributeTargets attrTarget; + if ((typeDef->mIsDelegate) || (typeDef->mIsFunction)) + attrTarget = BfAttributeTargets_Delegate; + else if (typeInstance->IsEnum()) + attrTarget = BfAttributeTargets_Enum; + else if (typeInstance->IsInterface()) + attrTarget = BfAttributeTargets_Interface; + else if (typeInstance->IsStruct()) + attrTarget = BfAttributeTargets_Struct; else - typeInstance->mCustomAttributes = GetCustomAttributes(typeDef->mTypeDeclaration->mAttributes, attrTarget); + attrTarget = BfAttributeTargets_Class; + if (!typeInstance->mTypeFailed) + { + // This allows us to avoid reentrancy when checking for inner types + SetAndRestoreValue prevSkipTypeProtectionChecks(typeInstance->mSkipTypeProtectionChecks, true); + if (typeDef->mIsCombinedPartial) + { + for (auto partialTypeDef : typeDef->mPartials) + { + if (partialTypeDef->mTypeDeclaration->mAttributes == NULL) + continue; + BfTypeState typeState; + typeState.mPrevState = mContext->mCurTypeState; + typeState.mCurTypeDef = partialTypeDef; + typeState.mTypeInstance = typeInstance; + SetAndRestoreValue prevTypeState(mContext->mCurTypeState, &typeState); + + if (typeInstance->mCustomAttributes == NULL) + typeInstance->mCustomAttributes = new BfCustomAttributes(); + GetCustomAttributes(typeInstance->mCustomAttributes, partialTypeDef->mTypeDeclaration->mAttributes, attrTarget); + } + } + else + typeInstance->mCustomAttributes = GetCustomAttributes(typeDef->mTypeDeclaration->mAttributes, attrTarget); + } } }