mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-14 22:34:09 +02:00
Fixed extern constraint checks
This commit is contained in:
parent
8d3d4e71ea
commit
093a617b56
1 changed files with 26 additions and 5 deletions
|
@ -1881,6 +1881,14 @@ bool BfMethodMatcher::CheckMethod(BfTypeInstance* targetTypeInstance, BfTypeInst
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int externConstraintIdx = 0; externConstraintIdx < (int)checkMethod->mExternalConstraints.size(); externConstraintIdx++)
|
||||||
|
{
|
||||||
|
auto genericParam = methodInstance->mMethodInfoEx->mGenericParams[checkMethod->mGenericParams.size() + externConstraintIdx];
|
||||||
|
BF_ASSERT(genericParam->mExternType != NULL);
|
||||||
|
if (!mModule->CheckGenericConstraints(BfGenericParamSource(methodInstance), genericParam->mExternType, NULL, genericParam, genericArgumentsSubstitute, NULL))
|
||||||
|
goto NoMatch;
|
||||||
|
}
|
||||||
|
|
||||||
// Method is applicable, check to see which method is better
|
// Method is applicable, check to see which method is better
|
||||||
if (mBestMethodDef != NULL)
|
if (mBestMethodDef != NULL)
|
||||||
{
|
{
|
||||||
|
@ -1926,7 +1934,7 @@ bool BfMethodMatcher::CheckMethod(BfTypeInstance* targetTypeInstance, BfTypeInst
|
||||||
ambiguousEntry.mMethodInstance = methodInstance;
|
ambiguousEntry.mMethodInstance = methodInstance;
|
||||||
if (genericArgumentsSubstitute != NULL)
|
if (genericArgumentsSubstitute != NULL)
|
||||||
ambiguousEntry.mBestMethodGenericArguments = *genericArgumentsSubstitute;
|
ambiguousEntry.mBestMethodGenericArguments = *genericArgumentsSubstitute;
|
||||||
if (methodInstance->GetNumGenericParams() != 0)
|
if (methodInstance->mMethodDef->mGenericParams.size() != 0)
|
||||||
{
|
{
|
||||||
BF_ASSERT(!ambiguousEntry.mBestMethodGenericArguments.empty());
|
BF_ASSERT(!ambiguousEntry.mBestMethodGenericArguments.empty());
|
||||||
}
|
}
|
||||||
|
@ -7906,10 +7914,23 @@ BfTypedValue BfExprEvaluator::MatchMethod(BfAstNode* targetSrc, BfMethodBoundExp
|
||||||
if (fieldVal.mType->IsGenericParam())
|
if (fieldVal.mType->IsGenericParam())
|
||||||
{
|
{
|
||||||
auto genericParam = mModule->GetGenericParamInstance((BfGenericParamType*)fieldVal.mType);
|
auto genericParam = mModule->GetGenericParamInstance((BfGenericParamType*)fieldVal.mType);
|
||||||
if ((genericParam->mTypeConstraint != NULL) &&
|
BfType* typeConstraint = genericParam->mTypeConstraint;
|
||||||
((genericParam->mTypeConstraint->IsDelegate()) || (genericParam->mTypeConstraint->IsFunction())))
|
|
||||||
|
if ((mModule->mCurMethodInstance != NULL) && (mModule->mCurMethodInstance->mIsUnspecialized) && (mModule->mCurMethodInstance->mMethodInfoEx != NULL))
|
||||||
{
|
{
|
||||||
BfMethodInstance* invokeMethodInstance = mModule->GetRawMethodInstanceAtIdx(genericParam->mTypeConstraint->ToTypeInstance(), 0, "Invoke");
|
for (int genericParamIdx = (int)mModule->mCurMethodInstance->mMethodInfoEx->mMethodGenericArguments.size();
|
||||||
|
genericParamIdx < mModule->mCurMethodInstance->mMethodInfoEx->mGenericParams.size(); genericParamIdx++)
|
||||||
|
{
|
||||||
|
auto genericParam = mModule->mCurMethodInstance->mMethodInfoEx->mGenericParams[genericParamIdx];
|
||||||
|
if ((genericParam->mExternType == fieldVal.mType) && (genericParam->mTypeConstraint != NULL))
|
||||||
|
typeConstraint = genericParam->mTypeConstraint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((typeConstraint != NULL) &&
|
||||||
|
((typeConstraint->IsDelegate()) || (typeConstraint->IsFunction())))
|
||||||
|
{
|
||||||
|
BfMethodInstance* invokeMethodInstance = mModule->GetRawMethodInstanceAtIdx(typeConstraint->ToTypeInstance(), 0, "Invoke");
|
||||||
|
|
||||||
methodDef = invokeMethodInstance->mMethodDef;
|
methodDef = invokeMethodInstance->mMethodDef;
|
||||||
methodMatcher.mBestMethodInstance = invokeMethodInstance;
|
methodMatcher.mBestMethodInstance = invokeMethodInstance;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue