diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index cfab1989..0347b999 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -3310,6 +3310,7 @@ BfType* BfExprEvaluator::BindGenericType(BfAstNode* node, BfType* bindType) auto genericTypeBindings = mModule->mCurMethodState->GetRootMethodState()->mGenericTypeBindings; auto methodInstance = mModule->mCurMethodInstance; + bool isMixinBind = false; if (mModule->mCurMethodState->mMixinState != NULL) { auto mixinMethodInstance = mModule->mCurMethodState->mMixinState->mMixinMethodInstance; @@ -3327,6 +3328,7 @@ BfType* BfExprEvaluator::BindGenericType(BfAstNode* node, BfType* bindType) mModule->mContext->ProcessMethod(unspecMixinMethodInstance); } + isMixinBind = true; methodInstance = mixinMethodInstance; genericTypeBindings = &unspecMixinMethodInstance->mMethodInfoEx->mGenericTypeBindings; } @@ -3334,6 +3336,9 @@ BfType* BfExprEvaluator::BindGenericType(BfAstNode* node, BfType* bindType) if ((methodInstance->mIsUnspecialized) && (!methodInstance->mIsUnspecializedVariation)) { + if (isMixinBind) + return bindType; + if (!bindType->IsGenericParam()) return bindType; @@ -9604,7 +9609,7 @@ BfTypedValue BfExprEvaluator::MatchMethod(BfAstNode* targetSrc, BfMethodBoundExp } }; - auto genericParamInstance = mModule->GetGenericParamInstance(genericParamTarget); + auto genericParamInstance = mModule->GetGenericParamInstance(genericParamTarget, true); _HandleGenericParamInstance(genericParamInstance); // Check method generic constraints @@ -10794,7 +10799,7 @@ void BfExprEvaluator::LookupQualifiedName(BfQualifiedNameNode* nameNode, bool ig mResult = LookupField(nameNode->mRight, lookupVal, fieldName); if ((!mResult) && (mPropDef == NULL) && (lookupType->IsGenericParam())) { - auto genericParamInst = mModule->GetGenericParamInstance((BfGenericParamType*)lookupType); + auto genericParamInst = mModule->GetGenericParamInstance((BfGenericParamType*)lookupType, true); SizedArray searchConstraints; for (auto ifaceConstraint : genericParamInst->mInterfaceConstraints) { @@ -10990,7 +10995,7 @@ void BfExprEvaluator::LookupQualifiedName(BfAstNode* nameNode, BfIdentifierNode* if ((!mResult) && (mPropDef == NULL) && (lookupType->IsGenericParam())) { - auto genericParamInst = mModule->GetGenericParamInstance((BfGenericParamType*)lookupType); + auto genericParamInst = mModule->GetGenericParamInstance((BfGenericParamType*)lookupType, true); SizedArray searchConstraints; for (auto ifaceConstraint : genericParamInst->mInterfaceConstraints) { diff --git a/IDEHelper/Compiler/BfModule.h b/IDEHelper/Compiler/BfModule.h index c6c2c363..6c0d62dd 100644 --- a/IDEHelper/Compiler/BfModule.h +++ b/IDEHelper/Compiler/BfModule.h @@ -1922,7 +1922,7 @@ public: BfType* ResolveSelfType(BfType* type, BfType* selfType); bool IsUnboundGeneric(BfType* type); BfGenericParamInstance* GetGenericTypeParamInstance(int paramIdx); - BfGenericParamInstance* GetGenericParamInstance(BfGenericParamType* type); + BfGenericParamInstance* GetGenericParamInstance(BfGenericParamType* type, bool checkMixinBind = false); void GetActiveTypeGenericParamInstances(SizedArray& genericParamInstance); BfGenericParamInstance* GetMergedGenericParamData(BfGenericParamType* type, BfGenericParamFlags& outFlags, BfType*& outTypeConstraint); BfTypeInstance* GetBaseType(BfTypeInstance* typeInst); diff --git a/IDEHelper/Compiler/BfModuleTypeUtils.cpp b/IDEHelper/Compiler/BfModuleTypeUtils.cpp index 41cecb04..4c85bd8d 100644 --- a/IDEHelper/Compiler/BfModuleTypeUtils.cpp +++ b/IDEHelper/Compiler/BfModuleTypeUtils.cpp @@ -9353,12 +9353,12 @@ BfGenericParamInstance* BfModule::GetMergedGenericParamData(BfGenericParamType* return genericParam; } -BfGenericParamInstance* BfModule::GetGenericParamInstance(BfGenericParamType* type) +BfGenericParamInstance* BfModule::GetGenericParamInstance(BfGenericParamType* type, bool checkMixinBind) { if (type->mGenericParamKind == BfGenericParamKind_Method) { auto curGenericMethodInstance = mCurMethodInstance; - if ((mCurMethodState != NULL) && (mCurMethodState->mMixinState != NULL)) + if ((checkMixinBind) && (mCurMethodState != NULL) && (mCurMethodState->mMixinState != NULL)) curGenericMethodInstance = mCurMethodState->mMixinState->mMixinMethodInstance; if ((curGenericMethodInstance == NULL) || (curGenericMethodInstance->mMethodInfoEx == NULL) || (type->mGenericParamIdx >= curGenericMethodInstance->mMethodInfoEx->mGenericParams.mSize)) @@ -15681,8 +15681,7 @@ void BfModule::DoTypeToString(StringImpl& str, BfType* resolvedType, BfTypeNameF return; } } - - //TEMPORARY + if (genericParam->mGenericParamKind == BfGenericParamKind_Type) { auto curTypeInstance = mCurTypeInstance; @@ -15696,6 +15695,12 @@ void BfModule::DoTypeToString(StringImpl& str, BfType* resolvedType, BfTypeNameF } auto genericParamInstance = GetGenericParamInstance(genericParam); + if (genericParamInstance == NULL) + { + str += StrFormat("@M%d", genericParam->mGenericParamIdx); + return; + } + auto genericParamDef = genericParamInstance->GetGenericParamDef(); if (genericParamDef != NULL) str += genericParamInstance->GetGenericParamDef()->mName;