mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Fixed invalid generic inference from generic constraints
This commit is contained in:
parent
4189d10f41
commit
03e28f3add
4 changed files with 35 additions and 3 deletions
|
@ -243,6 +243,16 @@ bool BfGenericInferContext::InferGenericArgument(BfMethodInstance* methodInstanc
|
|||
if (argType == NULL)
|
||||
return false;
|
||||
|
||||
if (mIgnoreMethodGenericParam)
|
||||
{
|
||||
if (argType->IsGenericParam())
|
||||
{
|
||||
auto genericParamType = (BfGenericParamType*)argType;
|
||||
if (genericParamType->mGenericParamKind == BfGenericParamKind_Method)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!wantType->IsUnspecializedType())
|
||||
return true;
|
||||
|
||||
|
@ -623,10 +633,12 @@ bool BfGenericInferContext::InferGenericArguments(BfMethodInstance* methodInstan
|
|||
else
|
||||
genericParam = mModule->GetGenericParamInstance(genericParamType);
|
||||
|
||||
// Generic arg references in constraints refer to the caller, not the callee -- so ignore those
|
||||
SetAndRestoreValue<bool> prevIgnoreMethodGenericArg(mIgnoreMethodGenericParam, true);
|
||||
if (genericParam->mTypeConstraint != NULL)
|
||||
InferGenericArgument(methodInstance, genericParam->mTypeConstraint, ifaceConstraint, BfIRValue());
|
||||
for (auto argIfaceConstraint : genericParam->mInterfaceConstraints)
|
||||
InferGenericArgument(methodInstance, argIfaceConstraint, ifaceConstraint, BfIRValue());
|
||||
InferGenericArgument(methodInstance, argIfaceConstraint, ifaceConstraint, BfIRValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue