1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 20:42:21 +02:00

Fixed arg name failure in generic method selection

This commit is contained in:
Brian Fiete 2022-07-26 15:12:25 -04:00
parent 5416d30bf1
commit 1a85562d54

View file

@ -1752,38 +1752,6 @@ bool BfMethodMatcher::CheckMethod(BfTypeInstance* targetTypeInstance, BfTypeInst
}
}
if (mHasArgNames)
{
checkMethod->BuildParamNameMap();
bool prevWasNull = false;
for (int argIdx = (int)mArguments.mSize - 1; argIdx >= 0; argIdx--)
{
auto& arg = mArguments[argIdx];
if (arg.mNameNode != NULL)
{
if (prevWasNull)
{
if (argIdx >= checkMethod->mParams.mSize)
goto NoMatch;
if (checkMethod->mParams[argIdx]->mName != arg.mNameNode->ToStringView())
goto NoMatch;
}
else
{
if (!checkMethod->mParamNameMap->ContainsKey(arg.mNameNode->ToStringView()))
goto NoMatch;
}
prevWasNull = false;
}
else
{
prevWasNull = true;
}
}
}
for (auto& checkGenericArgRef : mCheckMethodGenericArguments)
checkGenericArgRef = NULL;
@ -1820,6 +1788,38 @@ bool BfMethodMatcher::CheckMethod(BfTypeInstance* targetTypeInstance, BfTypeInst
else if (needInferGenericParams)
genericArgumentsSubstitute = &mCheckMethodGenericArguments;
if (mHasArgNames)
{
checkMethod->BuildParamNameMap();
bool prevWasNull = false;
for (int argIdx = (int)mArguments.mSize - 1; argIdx >= 0; argIdx--)
{
auto& arg = mArguments[argIdx];
if (arg.mNameNode != NULL)
{
if (prevWasNull)
{
if (argIdx >= checkMethod->mParams.mSize)
goto NoMatch;
if (checkMethod->mParams[argIdx]->mName != arg.mNameNode->ToStringView())
goto NoMatch;
}
else
{
if (!checkMethod->mParamNameMap->ContainsKey(arg.mNameNode->ToStringView()))
goto NoMatch;
}
prevWasNull = false;
}
else
{
prevWasNull = true;
}
}
}
if ((checkMethod->mIsMutating) && (targetTypeInstance != NULL) && (targetTypeInstance->IsValueType()) &&
((mTarget.IsReadOnly()) || (!mTarget.IsAddr())) &&
(!targetTypeInstance->IsValuelessType()))