MCPcopy Create free account
hub / github.com/beefytech/Beef / CheckGenericConstraints

Method CheckGenericConstraints

IDEHelper/Compiler/BfModule.cpp:8686–9227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8684}
8685
8686bool BfModule::CheckGenericConstraints(const BfGenericParamSource& genericParamSource, BfType* checkArgType, BfAstNode* checkArgTypeRef, BfGenericParamInstance* genericParamInst, BfTypeVector* methodGenericArgs, BfError** errorOut)
8687{
8688 Array<String> methodParamNameOverrides;
8689 auto _TypeToString = [&](BfType* type)
8690 {
8691 if (genericParamSource.mMethodInstance != NULL)
8692 {
8693 if (methodParamNameOverrides.IsEmpty())
8694 {
8695 for (auto genericParam : genericParamSource.mMethodInstance->mMethodDef->mGenericParams)
8696 methodParamNameOverrides.Add(genericParam->mName);
8697 }
8698 return TypeToString(type, &methodParamNameOverrides);
8699 }
8700 return TypeToString(type);
8701 };
8702
8703 bool ignoreErrors = (errorOut == NULL) ||
8704 ((genericParamSource.mMethodInstance == NULL) && (genericParamSource.mTypeInstance == NULL));
8705
8706 if (checkArgType->IsVar())
8707 return true;
8708
8709 BfType* origCheckArgType = checkArgType;
8710
8711 if (origCheckArgType->IsRef())
8712 origCheckArgType = origCheckArgType->GetUnderlyingType();
8713
8714 bool argIsReferenceType = false;
8715
8716 int checkGenericParamFlags = 0;
8717 if (checkArgType->IsGenericParam())
8718 {
8719 BfGenericParamInstance* checkGenericParamInst = GetGenericParamInstance((BfGenericParamType*)checkArgType);
8720 checkGenericParamFlags = checkGenericParamInst->mGenericParamFlags;
8721 if (checkGenericParamInst->mTypeConstraint != NULL)
8722 checkArgType = checkGenericParamInst->mTypeConstraint;
8723 if (checkGenericParamInst->mGenericParamFlags & BfGenericParamFlag_Var)
8724 checkArgType = GetPrimitiveType(BfTypeCode_Var);
8725
8726// if ((checkGenericParamFlags & (BfGenericParamFlag_Struct | BfGenericParamFlag_StructPtr)) != 0)
8727// {
8728// argMayBeReferenceType = false;
8729// }
8730// else
8731// {
8732// argMayBeReferenceType = true;
8733// }
8734 }
8735
8736 if (checkArgType->IsObjectOrInterface())
8737 argIsReferenceType = true;
8738
8739 if ((mCurMethodInstance != NULL) && (mCurMethodInstance->mIsUnspecialized) && (mCurMethodInstance->mMethodInfoEx != NULL))
8740 {
8741 for (int genericParamIdx = (int)mCurMethodInstance->mMethodInfoEx->mMethodGenericArguments.size();
8742 genericParamIdx < mCurMethodInstance->mMethodInfoEx->mGenericParams.size(); genericParamIdx++)
8743 {

Callers 5

AddExtensionMethodsMethod · 0.80
CheckMethodMethod · 0.80
GetSelectedMethodMethod · 0.80
InjectMixinMethod · 0.80
IsTypeMemberIncludedMethod · 0.80

Calls 15

TypeToStringFunction · 0.85
FailFunction · 0.85
StringClass · 0.85
BfTypedValueClass · 0.85
PopulateMemberSetsMethod · 0.80
TryGetWithMethod · 0.80
DoesLiteralFitMethod · 0.80
HasExplicitThisMethod · 0.80
IsExactMethodMatchMethod · 0.80
GetFakeValMethod · 0.80
PerformUnaryOperationMethod · 0.80
IsEmptyMethod · 0.45

Tested by

no test coverage detected