From f466a2ea576cebe70151f90a114a6424e3a284a4 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Sat, 1 Feb 2025 12:19:49 -0800 Subject: [PATCH] Properly use method generic arguments from methodrefs --- IDEHelper/Compiler/BfExprEvaluator.cpp | 6 ++++++ IDEHelper/Tests/src/FuncRefs.bf | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index 6fafe228..3de8a7ec 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -10500,6 +10500,12 @@ BfTypedValue BfExprEvaluator::MatchMethod(BfAstNode* targetSrc, BfMethodBoundExp methodGenericArguments = methodInstance->mMethodInfoEx->mMethodGenericArguments; methodMatcher.mBestMethodInstance = mModule->GetMethodInstance(methodInstance->GetOwner(), methodInstance->mMethodDef, methodGenericArguments); } + + if (methodInstance->mMethodInfoEx != NULL) + { + methodMatcher.mBestMethodGenericArguments = methodInstance->mMethodInfoEx->mMethodGenericArguments; + } + methodMatcher.mBestMethodTypeInstance = methodInstance->GetOwner(); if (methodInstance->HasThis()) { diff --git a/IDEHelper/Tests/src/FuncRefs.bf b/IDEHelper/Tests/src/FuncRefs.bf index 2ad01a03..3660da25 100644 --- a/IDEHelper/Tests/src/FuncRefs.bf +++ b/IDEHelper/Tests/src/FuncRefs.bf @@ -483,6 +483,21 @@ namespace Tests } } + public static void Test(F func) + where F: delegate void(delegate void(String, params Span)) + { + String str = scope .(); + + delegate void(String, params Span) setError = scope (errStr, args) => { str.AppendF(errStr, params args); }; + delegate void() call = scope () => func(setError); + call(); + } + + public static void Test() where T : var + { + Test((e) => e("hi!")); + } + [Test] public static void ClassTestA() { @@ -499,6 +514,8 @@ namespace Tests val.Test(); val = .(); val.TestDlg(); + + Test(); } [Test]