mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Improved generic binding in mixins
This commit is contained in:
parent
6cfd027362
commit
1183007a90
3 changed files with 18 additions and 8 deletions
|
@ -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<BfTypeInstance*, 8> 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<BfTypeInstance*, 8> searchConstraints;
|
||||
for (auto ifaceConstraint : genericParamInst->mInterfaceConstraints)
|
||||
{
|
||||
|
|
|
@ -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<BfGenericParamInstance*, 4>& genericParamInstance);
|
||||
BfGenericParamInstance* GetMergedGenericParamData(BfGenericParamType* type, BfGenericParamFlags& outFlags, BfType*& outTypeConstraint);
|
||||
BfTypeInstance* GetBaseType(BfTypeInstance* typeInst);
|
||||
|
|
|
@ -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))
|
||||
|
@ -15682,7 +15682,6 @@ void BfModule::DoTypeToString(StringImpl& str, BfType* resolvedType, BfTypeNameF
|
|||
}
|
||||
}
|
||||
|
||||
//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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue