From a681da30be45f303e1d543dfca4ef8e6c7cdb814 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Fri, 15 Jan 2021 14:59:02 -0800 Subject: [PATCH] Removed '=' in generic constraints --- BeefLibs/corlib/src/Nullable.bf | 60 +++++++++++------------ IDE/mintest/minlib/src/System/Nullable.bf | 60 +++++++++++------------ IDEHelper/Compiler/BfDefBuilder.cpp | 16 +----- IDEHelper/Compiler/BfExprEvaluator.cpp | 22 ++------- IDEHelper/Compiler/BfModule.cpp | 16 ++---- IDEHelper/Compiler/BfReducer.cpp | 2 +- 6 files changed, 69 insertions(+), 107 deletions(-) diff --git a/BeefLibs/corlib/src/Nullable.bf b/BeefLibs/corlib/src/Nullable.bf index fbc1add9..b32165d2 100644 --- a/BeefLibs/corlib/src/Nullable.bf +++ b/BeefLibs/corlib/src/Nullable.bf @@ -236,17 +236,17 @@ namespace System /// - public static TResult? operator+(Nullable lhs, TOther rhs) where TResult = operator T + TOther where TResult : struct + public static TResult? operator+(Nullable lhs, TOther rhs) where TResult : operator T + TOther where TResult : struct { if (!lhs.mHasValue) return null; return Nullable(lhs.mValue + rhs); } - public static TResult? operator+(TOther lhs, Nullable rhs) where TResult = operator TOther + T where TResult : struct + public static TResult? operator+(TOther lhs, Nullable rhs) where TResult : operator TOther + T where TResult : struct { if (!rhs.mHasValue) return null; return Nullable(lhs + rhs.mValue); } - public static TResult? operator+(Nullable lhs, Nullable rhs) where TOther : struct where TResult = operator T + TOther where TResult : struct + public static TResult? operator+(Nullable lhs, Nullable rhs) where TOther : struct where TResult : operator T + TOther where TResult : struct { if ((!lhs.mHasValue) || (!rhs.mHasValue)) return null; return Nullable(lhs.mValue + rhs.mValue); @@ -254,19 +254,19 @@ namespace System /// - public static TResult? operator-(TOther lhs, Nullable rhs) where TResult = operator TOther - T where TResult : struct + public static TResult? operator-(TOther lhs, Nullable rhs) where TResult : operator TOther - T where TResult : struct { if (!rhs.mHasValue) return null; return Nullable(lhs - rhs.mValue); } - public static TResult? operator-(Nullable lhs, TOther rhs) where TResult = operator T - TOther where TResult : struct + public static TResult? operator-(Nullable lhs, TOther rhs) where TResult : operator T - TOther where TResult : struct { if (!lhs.mHasValue) return null; return Nullable(lhs.mValue - rhs); } - public static TResult? operator-(Nullable lhs, Nullable rhs) where TOther : struct where TResult = operator T - TOther where TResult : struct + public static TResult? operator-(Nullable lhs, Nullable rhs) where TOther : struct where TResult : operator T - TOther where TResult : struct { if ((!lhs.mHasValue) || (!rhs.mHasValue)) return null; return Nullable(lhs.mValue - rhs.mValue); @@ -274,19 +274,19 @@ namespace System // - public static TResult? operator*(TOther lhs, Nullable rhs) where TResult = operator TOther * T where TResult : struct + public static TResult? operator*(TOther lhs, Nullable rhs) where TResult : operator TOther * T where TResult : struct { if (!rhs.mHasValue) return null; return Nullable(lhs * rhs.mValue); } - public static TResult? operator*(Nullable lhs, TOther rhs) where TResult = operator T * TOther where TResult : struct + public static TResult? operator*(Nullable lhs, TOther rhs) where TResult : operator T * TOther where TResult : struct { if (!lhs.mHasValue) return null; return Nullable(lhs.mValue * rhs); } - public static TResult? operator*(Nullable lhs, Nullable rhs) where TOther : struct where TResult = operator T * TOther where TResult : struct + public static TResult? operator*(Nullable lhs, Nullable rhs) where TOther : struct where TResult : operator T * TOther where TResult : struct { if ((!lhs.mHasValue) || (!rhs.mHasValue)) return null; return Nullable(lhs.mValue * rhs.mValue); @@ -294,19 +294,19 @@ namespace System // - public static TResult? operator/(TOther lhs, Nullable rhs) where TResult = operator TOther / T where TResult : struct + public static TResult? operator/(TOther lhs, Nullable rhs) where TResult : operator TOther / T where TResult : struct { if (!rhs.mHasValue) return null; return Nullable(lhs / rhs.mValue); } - public static TResult? operator/(Nullable lhs, TOther rhs) where TResult = operator T / TOther where TResult : struct + public static TResult? operator/(Nullable lhs, TOther rhs) where TResult : operator T / TOther where TResult : struct { if (!lhs.mHasValue) return null; return Nullable(lhs.mValue / rhs); } - public static TResult? operator/(Nullable lhs, Nullable rhs) where TOther : struct where TResult = operator T / TOther where TResult : struct + public static TResult? operator/(Nullable lhs, Nullable rhs) where TOther : struct where TResult : operator T / TOther where TResult : struct { if ((!lhs.mHasValue) || (!rhs.mHasValue)) return null; return Nullable(lhs.mValue / rhs.mValue); @@ -314,19 +314,19 @@ namespace System // - public static TResult? operator%(TOther lhs, Nullable rhs) where TResult = operator TOther % T where TResult : struct + public static TResult? operator%(TOther lhs, Nullable rhs) where TResult : operator TOther % T where TResult : struct { if (!rhs.mHasValue) return null; return Nullable(lhs % rhs.mValue); } - public static TResult? operator%(Nullable lhs, TOther rhs) where TResult = operator T % TOther where TResult : struct + public static TResult? operator%(Nullable lhs, TOther rhs) where TResult : operator T % TOther where TResult : struct { if (!lhs.mHasValue) return null; return Nullable(lhs.mValue % rhs); } - public static TResult? operator%(Nullable lhs, Nullable rhs) where TOther : struct where TResult = operator T % TOther where TResult : struct + public static TResult? operator%(Nullable lhs, Nullable rhs) where TOther : struct where TResult : operator T % TOther where TResult : struct { if ((!lhs.mHasValue) || (!rhs.mHasValue)) return null; return Nullable(lhs.mValue % rhs.mValue); @@ -334,19 +334,19 @@ namespace System // - public static TResult? operator^(TOther lhs, Nullable rhs) where TResult = operator TOther ^ T where TResult : struct + public static TResult? operator^(TOther lhs, Nullable rhs) where TResult : operator TOther ^ T where TResult : struct { if (!rhs.mHasValue) return null; return Nullable(lhs ^ rhs.mValue); } - public static TResult? operator^(Nullable lhs, TOther rhs) where TResult = operator T ^ TOther where TResult : struct + public static TResult? operator^(Nullable lhs, TOther rhs) where TResult : operator T ^ TOther where TResult : struct { if (!lhs.mHasValue) return null; return Nullable(lhs.mValue ^ rhs); } - public static TResult? operator^(Nullable lhs, Nullable rhs) where TOther : struct where TResult = operator T ^ TOther where TResult : struct + public static TResult? operator^(Nullable lhs, Nullable rhs) where TOther : struct where TResult : operator T ^ TOther where TResult : struct { if ((!lhs.mHasValue) || (!rhs.mHasValue)) return null; return Nullable(lhs.mValue ^ rhs.mValue); @@ -354,19 +354,19 @@ namespace System // - public static TResult? operator&(TOther lhs, Nullable rhs) where TResult = operator TOther & T where TResult : struct + public static TResult? operator&(TOther lhs, Nullable rhs) where TResult : operator TOther & T where TResult : struct { if (!rhs.mHasValue) return null; return Nullable(lhs & rhs.mValue); } - public static TResult? operator&(Nullable lhs, TOther rhs) where TResult = operator T & TOther where TResult : struct + public static TResult? operator&(Nullable lhs, TOther rhs) where TResult : operator T & TOther where TResult : struct { if (!lhs.mHasValue) return null; return Nullable(lhs.mValue & rhs); } - public static TResult? operator&(Nullable lhs, Nullable rhs) where TOther : struct where TResult = operator T & TOther where TResult : struct + public static TResult? operator&(Nullable lhs, Nullable rhs) where TOther : struct where TResult : operator T & TOther where TResult : struct { if ((!lhs.mHasValue) || (!rhs.mHasValue)) return null; return Nullable(lhs.mValue & rhs.mValue); @@ -374,19 +374,19 @@ namespace System // - public static TResult? operator|(TOther lhs, Nullable rhs) where TResult = operator TOther | T where TResult : struct + public static TResult? operator|(TOther lhs, Nullable rhs) where TResult : operator TOther | T where TResult : struct { if (!rhs.mHasValue) return null; return Nullable(lhs | rhs.mValue); } - public static TResult? operator|(Nullable lhs, TOther rhs) where TResult = operator T | TOther where TResult : struct + public static TResult? operator|(Nullable lhs, TOther rhs) where TResult : operator T | TOther where TResult : struct { if (!lhs.mHasValue) return null; return Nullable(lhs.mValue | rhs); } - public static TResult? operator|(Nullable lhs, Nullable rhs) where TOther : struct where TResult = operator T | TOther where TResult : struct + public static TResult? operator|(Nullable lhs, Nullable rhs) where TOther : struct where TResult : operator T | TOther where TResult : struct { if ((!lhs.mHasValue) || (!rhs.mHasValue)) return null; return Nullable(lhs.mValue | rhs.mValue); @@ -399,19 +399,19 @@ namespace System return (lhs.mHasValue) ? lhs.mValue : rhs; } - public static TResult? operator??(TOther lhs, Nullable rhs) where TResult = operator TOther ?? T where TResult : struct + public static TResult? operator??(TOther lhs, Nullable rhs) where TResult : operator TOther ?? T where TResult : struct { if (!rhs.mHasValue) return null; return Nullable(lhs ?? rhs.mValue); } - public static TResult? operator??(Nullable lhs, TOther rhs) where TResult = operator T ?? TOther where TResult : struct + public static TResult? operator??(Nullable lhs, TOther rhs) where TResult : operator T ?? TOther where TResult : struct { if (!lhs.mHasValue) return null; return Nullable(lhs.mValue ?? rhs); } - public static TResult? operator??(Nullable lhs, Nullable rhs) where TOther : struct where TResult = operator T ?? TOther where TResult : struct + public static TResult? operator??(Nullable lhs, Nullable rhs) where TOther : struct where TResult : operator T ?? TOther where TResult : struct { if ((!lhs.mHasValue) || (!rhs.mHasValue)) return null; return Nullable(lhs.mValue ?? rhs.mValue); @@ -419,19 +419,19 @@ namespace System // - public static TResult? operator<< (TOther lhs, Nullable rhs) where TResult = operator TOther << T where TResult : struct + public static TResult? operator<< (TOther lhs, Nullable rhs) where TResult : operator TOther << T where TResult : struct { if (!rhs.mHasValue) return null; return Nullable(lhs << rhs.mValue); } - public static TResult? operator<< (Nullable lhs, TOther rhs) where TResult = operator T << TOther where TResult : struct + public static TResult? operator<< (Nullable lhs, TOther rhs) where TResult : operator T << TOther where TResult : struct { if (!lhs.mHasValue) return null; return Nullable(lhs.mValue << rhs); } - public static TResult? operator<< (Nullable lhs, Nullable rhs) where TOther : struct where TResult = operator T << TOther where TResult : struct + public static TResult? operator<< (Nullable lhs, Nullable rhs) where TOther : struct where TResult : operator T << TOther where TResult : struct { if ((!lhs.mHasValue) || (!rhs.mHasValue)) return null; return Nullable(lhs.mValue << rhs.mValue); diff --git a/IDE/mintest/minlib/src/System/Nullable.bf b/IDE/mintest/minlib/src/System/Nullable.bf index 428950b9..deb5392e 100644 --- a/IDE/mintest/minlib/src/System/Nullable.bf +++ b/IDE/mintest/minlib/src/System/Nullable.bf @@ -236,17 +236,17 @@ namespace System /// - public static TResult? operator+(Nullable lhs, TOther rhs) where TResult = operator T + TOther where TResult : struct + public static TResult? operator+(Nullable lhs, TOther rhs) where TResult : operator T + TOther where TResult : struct { if (!lhs.mHasValue) return null; return Nullable(lhs.mValue + rhs); } - public static TResult? operator+(TOther lhs, Nullable rhs) where TResult = operator TOther + T where TResult : struct + public static TResult? operator+(TOther lhs, Nullable rhs) where TResult : operator TOther + T where TResult : struct { if (!rhs.mHasValue) return null; return Nullable(lhs + rhs.mValue); } - public static TResult? operator+(Nullable lhs, Nullable rhs) where TOther : struct where TResult = operator T + TOther where TResult : struct + public static TResult? operator+(Nullable lhs, Nullable rhs) where TOther : struct where TResult : operator T + TOther where TResult : struct { if ((!lhs.mHasValue) || (!rhs.mHasValue)) return null; return Nullable(lhs.mValue + rhs.mValue); @@ -254,19 +254,19 @@ namespace System /// - public static TResult? operator-(TOther lhs, Nullable rhs) where TResult = operator TOther - T where TResult : struct + public static TResult? operator-(TOther lhs, Nullable rhs) where TResult : operator TOther - T where TResult : struct { if (!rhs.mHasValue) return null; return Nullable(lhs - rhs.mValue); } - public static TResult? operator-(Nullable lhs, TOther rhs) where TResult = operator T - TOther where TResult : struct + public static TResult? operator-(Nullable lhs, TOther rhs) where TResult : operator T - TOther where TResult : struct { if (!lhs.mHasValue) return null; return Nullable(lhs.mValue - rhs); } - public static TResult? operator-(Nullable lhs, Nullable rhs) where TOther : struct where TResult = operator T - TOther where TResult : struct + public static TResult? operator-(Nullable lhs, Nullable rhs) where TOther : struct where TResult : operator T - TOther where TResult : struct { if ((!lhs.mHasValue) || (!rhs.mHasValue)) return null; return Nullable(lhs.mValue - rhs.mValue); @@ -274,19 +274,19 @@ namespace System // - public static TResult? operator*(TOther lhs, Nullable rhs) where TResult = operator TOther * T where TResult : struct + public static TResult? operator*(TOther lhs, Nullable rhs) where TResult : operator TOther * T where TResult : struct { if (!rhs.mHasValue) return null; return Nullable(lhs * rhs.mValue); } - public static TResult? operator*(Nullable lhs, TOther rhs) where TResult = operator T * TOther where TResult : struct + public static TResult? operator*(Nullable lhs, TOther rhs) where TResult : operator T * TOther where TResult : struct { if (!lhs.mHasValue) return null; return Nullable(lhs.mValue * rhs); } - public static TResult? operator*(Nullable lhs, Nullable rhs) where TOther : struct where TResult = operator T * TOther where TResult : struct + public static TResult? operator*(Nullable lhs, Nullable rhs) where TOther : struct where TResult : operator T * TOther where TResult : struct { if ((!lhs.mHasValue) || (!rhs.mHasValue)) return null; return Nullable(lhs.mValue * rhs.mValue); @@ -294,19 +294,19 @@ namespace System // - public static TResult? operator/(TOther lhs, Nullable rhs) where TResult = operator TOther / T where TResult : struct + public static TResult? operator/(TOther lhs, Nullable rhs) where TResult : operator TOther / T where TResult : struct { if (!rhs.mHasValue) return null; return Nullable(lhs / rhs.mValue); } - public static TResult? operator/(Nullable lhs, TOther rhs) where TResult = operator T / TOther where TResult : struct + public static TResult? operator/(Nullable lhs, TOther rhs) where TResult : operator T / TOther where TResult : struct { if (!lhs.mHasValue) return null; return Nullable(lhs.mValue / rhs); } - public static TResult? operator/(Nullable lhs, Nullable rhs) where TOther : struct where TResult = operator T / TOther where TResult : struct + public static TResult? operator/(Nullable lhs, Nullable rhs) where TOther : struct where TResult : operator T / TOther where TResult : struct { if ((!lhs.mHasValue) || (!rhs.mHasValue)) return null; return Nullable(lhs.mValue / rhs.mValue); @@ -314,19 +314,19 @@ namespace System // - public static TResult? operator%(TOther lhs, Nullable rhs) where TResult = operator TOther % T where TResult : struct + public static TResult? operator%(TOther lhs, Nullable rhs) where TResult : operator TOther % T where TResult : struct { if (!rhs.mHasValue) return null; return Nullable(lhs % rhs.mValue); } - public static TResult? operator%(Nullable lhs, TOther rhs) where TResult = operator T % TOther where TResult : struct + public static TResult? operator%(Nullable lhs, TOther rhs) where TResult : operator T % TOther where TResult : struct { if (!lhs.mHasValue) return null; return Nullable(lhs.mValue % rhs); } - public static TResult? operator%(Nullable lhs, Nullable rhs) where TOther : struct where TResult = operator T % TOther where TResult : struct + public static TResult? operator%(Nullable lhs, Nullable rhs) where TOther : struct where TResult : operator T % TOther where TResult : struct { if ((!lhs.mHasValue) || (!rhs.mHasValue)) return null; return Nullable(lhs.mValue % rhs.mValue); @@ -334,19 +334,19 @@ namespace System // - public static TResult? operator^(TOther lhs, Nullable rhs) where TResult = operator TOther ^ T where TResult : struct + public static TResult? operator^(TOther lhs, Nullable rhs) where TResult : operator TOther ^ T where TResult : struct { if (!rhs.mHasValue) return null; return Nullable(lhs ^ rhs.mValue); } - public static TResult? operator^(Nullable lhs, TOther rhs) where TResult = operator T ^ TOther where TResult : struct + public static TResult? operator^(Nullable lhs, TOther rhs) where TResult : operator T ^ TOther where TResult : struct { if (!lhs.mHasValue) return null; return Nullable(lhs.mValue ^ rhs); } - public static TResult? operator^(Nullable lhs, Nullable rhs) where TOther : struct where TResult = operator T ^ TOther where TResult : struct + public static TResult? operator^(Nullable lhs, Nullable rhs) where TOther : struct where TResult : operator T ^ TOther where TResult : struct { if ((!lhs.mHasValue) || (!rhs.mHasValue)) return null; return Nullable(lhs.mValue ^ rhs.mValue); @@ -354,19 +354,19 @@ namespace System // - public static TResult? operator&(TOther lhs, Nullable rhs) where TResult = operator TOther & T where TResult : struct + public static TResult? operator&(TOther lhs, Nullable rhs) where TResult : operator TOther & T where TResult : struct { if (!rhs.mHasValue) return null; return Nullable(lhs & rhs.mValue); } - public static TResult? operator&(Nullable lhs, TOther rhs) where TResult = operator T & TOther where TResult : struct + public static TResult? operator&(Nullable lhs, TOther rhs) where TResult : operator T & TOther where TResult : struct { if (!lhs.mHasValue) return null; return Nullable(lhs.mValue & rhs); } - public static TResult? operator&(Nullable lhs, Nullable rhs) where TOther : struct where TResult = operator T & TOther where TResult : struct + public static TResult? operator&(Nullable lhs, Nullable rhs) where TOther : struct where TResult : operator T & TOther where TResult : struct { if ((!lhs.mHasValue) || (!rhs.mHasValue)) return null; return Nullable(lhs.mValue & rhs.mValue); @@ -374,19 +374,19 @@ namespace System // - public static TResult? operator|(TOther lhs, Nullable rhs) where TResult = operator TOther | T where TResult : struct + public static TResult? operator|(TOther lhs, Nullable rhs) where TResult : operator TOther | T where TResult : struct { if (!rhs.mHasValue) return null; return Nullable(lhs | rhs.mValue); } - public static TResult? operator|(Nullable lhs, TOther rhs) where TResult = operator T | TOther where TResult : struct + public static TResult? operator|(Nullable lhs, TOther rhs) where TResult : operator T | TOther where TResult : struct { if (!lhs.mHasValue) return null; return Nullable(lhs.mValue | rhs); } - public static TResult? operator|(Nullable lhs, Nullable rhs) where TOther : struct where TResult = operator T | TOther where TResult : struct + public static TResult? operator|(Nullable lhs, Nullable rhs) where TOther : struct where TResult : operator T | TOther where TResult : struct { if ((!lhs.mHasValue) || (!rhs.mHasValue)) return null; return Nullable(lhs.mValue | rhs.mValue); @@ -399,19 +399,19 @@ namespace System return (lhs.mHasValue) ? lhs.mValue : rhs; } - public static TResult? operator??(TOther lhs, Nullable rhs) where TResult = operator TOther ?? T where TResult : struct + public static TResult? operator??(TOther lhs, Nullable rhs) where TResult : operator TOther ?? T where TResult : struct { if (!rhs.mHasValue) return null; return Nullable(lhs ?? rhs.mValue); } - public static TResult? operator??(Nullable lhs, TOther rhs) where TResult = operator T ?? TOther where TResult : struct + public static TResult? operator??(Nullable lhs, TOther rhs) where TResult : operator T ?? TOther where TResult : struct { if (!lhs.mHasValue) return null; return Nullable(lhs.mValue ?? rhs); } - public static TResult? operator??(Nullable lhs, Nullable rhs) where TOther : struct where TResult = operator T ?? TOther where TResult : struct + public static TResult? operator??(Nullable lhs, Nullable rhs) where TOther : struct where TResult : operator T ?? TOther where TResult : struct { if ((!lhs.mHasValue) || (!rhs.mHasValue)) return null; return Nullable(lhs.mValue ?? rhs.mValue); @@ -419,19 +419,19 @@ namespace System // - public static TResult? operator<< (TOther lhs, Nullable rhs) where TResult = operator TOther << T where TResult : struct + public static TResult? operator<< (TOther lhs, Nullable rhs) where TResult : operator TOther << T where TResult : struct { if (!rhs.mHasValue) return null; return Nullable(lhs << rhs.mValue); } - public static TResult? operator<< (Nullable lhs, TOther rhs) where TResult = operator T << TOther where TResult : struct + public static TResult? operator<< (Nullable lhs, TOther rhs) where TResult : operator T << TOther where TResult : struct { if (!lhs.mHasValue) return null; return Nullable(lhs.mValue << rhs); } - public static TResult? operator<< (Nullable lhs, Nullable rhs) where TOther : struct where TResult = operator T << TOther where TResult : struct + public static TResult? operator<< (Nullable lhs, Nullable rhs) where TOther : struct where TResult : operator T << TOther where TResult : struct { if ((!lhs.mHasValue) || (!rhs.mHasValue)) return null; return Nullable(lhs.mValue << rhs.mValue); diff --git a/IDEHelper/Compiler/BfDefBuilder.cpp b/IDEHelper/Compiler/BfDefBuilder.cpp index 48d6d03b..8bc13fa3 100644 --- a/IDEHelper/Compiler/BfDefBuilder.cpp +++ b/IDEHelper/Compiler/BfDefBuilder.cpp @@ -281,9 +281,7 @@ void BfDefBuilder::ParseGenericParams(BfGenericParamsDeclaration* genericParamsD { name = tokenPairNode->mLeft->ToString() + tokenPairNode->mRight->ToString(); } - - bool hasEquals = (genericConstraint->mColonToken != NULL) && (genericConstraint->mColonToken->mToken == BfToken_AssignEquals); - + if (!name.empty()) { if ((name == "class") || (name == "struct") || (name == "struct*") || (name == "const") || (name == "var") || (name == "concrete") || (name == "interface") || (name == "enum")) @@ -355,18 +353,6 @@ void BfDefBuilder::ParseGenericParams(BfGenericParamsDeclaration* genericParamsD return; } } - - if (hasEquals) - { - if (constraintDef->mConstraints.IsEmpty()) - { - constraintDef->mGenericParamFlags = (BfGenericParamFlags)(constraintDef->mGenericParamFlags | BfGenericParamFlag_Equals); - } - else - { - Fail("Type assignment must be the first constraint", genericConstraint->mColonToken); - } - } constraintDef->mConstraints.Add(constraintNode); } diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index b9062b9a..e6cd1f49 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -1429,9 +1429,6 @@ bool BfMethodMatcher::WantsCheckMethod(BfProtectionCheckFlags& flags, BfTypeInst bool BfMethodMatcher::InferFromGenericConstraints(BfMethodInstance* methodInstance, BfGenericParamInstance* genericParamInst, BfTypeVector* methodGenericArgs) { -// if ((genericParamInst->mGenericParamFlags & BfGenericParamFlag_Equals) == 0) -// return false; - if (!genericParamInst->mExternType->IsGenericParam()) return false; @@ -1441,17 +1438,6 @@ bool BfMethodMatcher::InferFromGenericConstraints(BfMethodInstance* methodInstan BfType* checkArgType = NULL; - if ((genericParamInst->mGenericParamFlags & BfGenericParamFlag_Equals_Type) != 0) - { - checkArgType = genericParamInst->mTypeConstraint; - } - - if ((genericParamInst->mGenericParamFlags & BfGenericParamFlag_Equals_IFace) != 0) - { - if (!genericParamInst->mInterfaceConstraints.IsEmpty()) - checkArgType = genericParamInst->mInterfaceConstraints[0]; - } - for (auto& checkOpConstraint : genericParamInst->mOperatorConstraints) { auto leftType = checkOpConstraint.mLeftType; @@ -1491,8 +1477,8 @@ bool BfMethodMatcher::InferFromGenericConstraints(BfMethodInstance* methodInstan SetAndRestoreValue prevIgnoreWrites(mModule->mBfIRBuilder->mIgnoreWrites, true); exprEvaluator.PerformBinaryOperation(NULL, NULL, checkOpConstraint.mBinaryOp, NULL, BfBinOpFlag_NoClassify, leftValue, rightValue); } - - if ((genericParamInst->mGenericParamFlags & BfGenericParamFlag_Equals_Op) != 0) + + if (exprEvaluator.mResult) checkArgType = exprEvaluator.mResult.mType; } else @@ -1522,8 +1508,8 @@ bool BfMethodMatcher::InferFromGenericConstraints(BfMethodInstance* methodInstan BfExprEvaluator exprEvaluator(mModule); exprEvaluator.mResult = rightValue; exprEvaluator.PerformUnaryOperation(NULL, checkOpConstraint.mUnaryOp, NULL, BfUnaryOpFlag_IsConstraintCheck); - - if ((genericParamInst->mGenericParamFlags & BfGenericParamFlag_Equals_Op) != 0) + + if (exprEvaluator.mResult) checkArgType = exprEvaluator.mResult.mType; } } diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index fcbc5c67..11dce7cd 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -7213,9 +7213,7 @@ void BfModule::ResolveGenericParamConstraints(BfGenericParamInstance* genericPar continue; } } - - if ((constraintDef->mGenericParamFlags & BfGenericParamFlag_Equals) != 0) - genericParamInstance->mGenericParamFlags = (BfGenericParamFlags)(genericParamInstance->mGenericParamFlags | BfGenericParamFlag_Equals_Op); + genericParamInstance->mOperatorConstraints.Add(opConstraintInstance); continue; @@ -7322,21 +7320,13 @@ void BfModule::ResolveGenericParamConstraints(BfGenericParamInstance* genericPar } checkEquality = true; } - - if ((constraintDef->mGenericParamFlags & BfGenericParamFlag_Equals) != 0) - { - genericParamInstance->mGenericParamFlags = (BfGenericParamFlags)(genericParamInstance->mGenericParamFlags | BfGenericParamFlag_Equals_Type); - checkEquality = true; - } - + if (checkEquality) { genericParamInstance->mTypeConstraint = constraintType; } else if (constraintType->IsInterface()) - { - if ((constraintDef->mGenericParamFlags & BfGenericParamFlag_Equals) != 0) - genericParamInstance->mGenericParamFlags = (BfGenericParamFlags)(genericParamInstance->mGenericParamFlags | BfGenericParamFlag_Equals_IFace); + { genericParamInstance->mInterfaceConstraints.push_back(constraintType->ToTypeInstance()); } else diff --git a/IDEHelper/Compiler/BfReducer.cpp b/IDEHelper/Compiler/BfReducer.cpp index ccc6a701..b1d9f05c 100644 --- a/IDEHelper/Compiler/BfReducer.cpp +++ b/IDEHelper/Compiler/BfReducer.cpp @@ -9565,7 +9565,7 @@ BfGenericConstraintsDeclaration* BfReducer::CreateGenericConstraintsDeclaration( if (genericParamName != NULL) { MEMBER_SET(genericConstraint, mTypeRef, genericParamName); - tokenNode = ExpectTokenAfter(genericConstraint, BfToken_Colon, BfToken_AssignEquals); + tokenNode = ExpectTokenAfter(genericConstraint, BfToken_Colon); } else isDone = true;