Not optimization itself is due to the fact that this is not the function itself, but the code that they execute. You assign a const reference to an action, but there is no guarantee that the code they execute is not modified and / or cannot produce constant behavior. If you cannot guarantee or predict some kind of persistent behavior, nesting is usually not a good idea, since you can have an unpredictable flow of execution, hence behavior that the .net framework is not aimed at.
In your specific example, where we have simple "dummy" functions that can lead to some embedding, it is possible, but it looks like a very special case, and something is unlikely to happen in someone else's code, so the introduction of optimization in .net framework will have little benefit for everyone, therefore, I think it is not implemented in the CLR .
EDIT
As @Sriram Sakthivel pointed out: having a reflection in .net runtime , such a possible and unpredictable change in function at runtime is probably one of the main factors of concern to allow the structure to be either this function is a good candidate for overlay or not.
In addition, the @hvd comment in @Sriram Sakthivel's answer points out why the readonly keyword specifically simply cannot guarantee deterministic immutability.
source share