Browse Source

Fixed issue with 'sticky' methodrefs

Brian Fiete 4 years ago
parent
commit
d5203f44db
2 changed files with 14 additions and 3 deletions
  1. 10 3
      IDEHelper/Compiler/BfExprEvaluator.cpp
  2. 4 0
      IDEHelper/Compiler/BfResolvedTypeUtils.h

+ 10 - 3
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<BfLambdaBindExpression>());
@@ -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;

+ 4 - 0
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; }