-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Open
Labels
4 - In ReviewA fix for the issue is submitted for review.A fix for the issue is submitted for review.Area-CompilersCode Gen QualityRoom for improvement in the quality of the compiler's generated codeRoom for improvement in the quality of the compiler's generated code
Milestone
Description
Version Used:
4.4.0
Steps to Reproduce:
Compile the following code:
var func1 = StaticMethodsOptimization.StaticMethod;
var func2 = LocalFunction; // ALLOCATES
var func3 = StaticLocalFunction;
var func4 = () => { };
var func5 = static () => { };
func1();
func2();
func3();
func4();
func5();
void LocalFunction() { } // no closure
static void StaticLocalFunction() { }
public static class StaticMethodsOptimization {
public static void StaticMethod() { }
}
Expected Behavior:
All delegate instances cached.
Actual Behavior:
var func2 = LocalFunction;
line allocates new delegate instance on each evaluation despite LocalFunction
local function being effectively static
.
This feels suboptimal and non-symmetric with the behavior of lambda expression.
[jcouv update:] relates to recent work on caching the delegate for static methods #58288
Metadata
Metadata
Labels
4 - In ReviewA fix for the issue is submitted for review.A fix for the issue is submitted for review.Area-CompilersCode Gen QualityRoom for improvement in the quality of the compiler's generated codeRoom for improvement in the quality of the compiler's generated code