mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
Incorporate extern constraints from method in lookupField
This commit is contained in:
parent
8cd20d4866
commit
83bed6b004
1 changed files with 25 additions and 3 deletions
|
@ -4351,11 +4351,11 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
|
|||
|
||||
if (isUnspecializedSection)
|
||||
{
|
||||
auto origTarget = target;
|
||||
|
||||
if (genericParamInst->mTypeConstraint != NULL)
|
||||
{
|
||||
target.mType = genericParamInst->mTypeConstraint;
|
||||
if (target.mType->IsWrappableType())
|
||||
target.mType = mModule->GetWrappedStructType(target.mType);
|
||||
target.mType = genericParamInst->mTypeConstraint;
|
||||
}
|
||||
else
|
||||
target.mType = mModule->mContext->mBfObjectType;
|
||||
|
@ -4364,6 +4364,28 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
|
|||
{
|
||||
target.mType = mModule->GetPrimitiveType(BfTypeCode_Var);
|
||||
}
|
||||
|
||||
if (origTarget.mType->IsTypeGenericParam())
|
||||
{
|
||||
// Check for extern constraint in method generic params
|
||||
if ((mModule->mCurMethodInstance != NULL) && (mModule->mCurMethodInstance->mMethodInfoEx != NULL))
|
||||
{
|
||||
for (auto genericParam : mModule->mCurMethodInstance->mMethodInfoEx->mGenericParams)
|
||||
{
|
||||
if (genericParam->mExternType == origTarget.mType)
|
||||
{
|
||||
if (genericParam->mTypeConstraint != NULL)
|
||||
{
|
||||
target.mType = genericParam->mTypeConstraint;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (target.mType->IsWrappableType())
|
||||
target.mType = mModule->GetWrappedStructType(target.mType);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue