From d5203f44dbd749a54228307b5d04a443f1a9d06b Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Tue, 19 Jan 2021 13:52:36 -0800 Subject: [PATCH] Fixed issue with 'sticky' methodrefs --- IDEHelper/Compiler/BfExprEvaluator.cpp | 13 ++++++++++--- IDEHelper/Compiler/BfResolvedTypeUtils.h | 4 ++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index f85d5f1e..d2d00981 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -1218,7 +1218,14 @@ BfTypedValue BfMethodMatcher::ResolveArgTypedValue(BfResolvedArg& resolvedArg, B } } else if ((resolvedArg.mArgFlags & BfArgFlag_LambdaBindAttempt) != 0) - { + { + if ((argTypedValue) && (argTypedValue.mType->IsMethodRef()) && + ((checkType == NULL) || (!checkType->IsMethodRef()))) + { + // This may be from a previous checkMethod, clear it out + argTypedValue = BfTypedValue(); + } + BfExprEvaluator exprEvaluator(mModule); exprEvaluator.mExpectingType = checkType; BF_ASSERT(resolvedArg.mExpression->IsA()); @@ -1246,11 +1253,11 @@ BfTypedValue BfMethodMatcher::ResolveArgTypedValue(BfResolvedArg& resolvedArg, B } } } - else if ((checkType == NULL) && (origCheckType != NULL) && (origCheckType->IsUnspecializedTypeVariation()) && (genericArgumentsSubstitute != NULL)) + else if ((checkType == NULL) && (origCheckType != NULL) && (origCheckType->IsUnspecializedTypeVariation()) && (genericArgumentsSubstitute != NULL) && (origCheckType->IsDelegateOrFunction())) { BfMethodInstance* methodInstance = mModule->GetRawMethodInstanceAtIdx(origCheckType->ToTypeInstance(), 0, "Invoke"); if (methodInstance != NULL) - { + { if ((methodInstance->mReturnType->IsGenericParam()) && (((BfGenericParamType*)methodInstance->mReturnType)->mGenericParamKind == BfGenericParamKind_Method)) { bool isValid = true; diff --git a/IDEHelper/Compiler/BfResolvedTypeUtils.h b/IDEHelper/Compiler/BfResolvedTypeUtils.h index 2ad3403a..905e4291 100644 --- a/IDEHelper/Compiler/BfResolvedTypeUtils.h +++ b/IDEHelper/Compiler/BfResolvedTypeUtils.h @@ -547,6 +547,7 @@ public: virtual bool IsArray() { return false; } virtual bool IsDelegate() { return false; } virtual bool IsFunction() { return false; } + virtual bool IsDelegateOrFunction() { return false; } virtual bool IsDelegateFromTypeRef() { return false; } virtual bool IsFunctionFromTypeRef() { return false; } virtual BfDelegateInfo* GetDelegateInfo() { return NULL; } @@ -1926,6 +1927,7 @@ public: virtual bool IsUnion() override { return mIsUnion; } virtual bool IsDelegate() override { return mTypeDef->mIsDelegate; } virtual bool IsFunction() override { return mTypeDef->mIsFunction; } + virtual bool IsDelegateOrFunction() override { return mTypeDef->mIsDelegate || mTypeDef->mIsFunction; } virtual bool IsString() override; virtual bool IsIntPtrable() override { return (mTypeDef->mTypeCode == BfTypeCode_Object) || (mTypeDef->mTypeCode == BfTypeCode_Interface); }; virtual bool IsEnum() override { return mTypeDef->mTypeCode == BfTypeCode_Enum; } @@ -2140,6 +2142,8 @@ public: virtual bool IsFunction() override { return !mTypeDef->mIsDelegate; } virtual bool IsFunctionFromTypeRef() override { return !mTypeDef->mIsDelegate; } + virtual bool IsDelegateOrFunction() override { return mTypeDef->mIsDelegate || mTypeDef->mIsFunction; } + virtual bool IsUnspecializedType() override { return mIsUnspecializedType; } virtual bool IsUnspecializedTypeVariation() override { return mIsUnspecializedTypeVariation; }