You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code is disallowed by the spec, but allowed by the Microsoft 4.0 spec and the roslyn compiler.
using System;
C.M(null); // bound to M(Func<int>)
public class C
{
public static void M(Func<int> func) {}
public static void M(Action action) {}
}
In that version, the “Better conversion from Expression” contains this as part of the tie breakers to determine that D1 is better than D2:
E is an anonymous function, T1 is either a delegate type D1 or an expression tree type Expression, T2 is either a delegate type D2 or an expression tree type Expression and one of the following holds:
D1 is a better conversion target than D2.
D1 and D2 have identical parameter lists, and one of the following holds:
D1 has a return type Y1, and D2 has a return type Y2, an inferred return type X exists for E in the context of that parameter list, and the conversion from X to Y1 is better than the conversion from X to Y2.
D1 has a return type Y, and D2 is void returning.
That final bullet is no longer in 12.6.4.7 (better conversion target) or 12.6.4.5 (better conversion from expression). I wonder if it was dropped erroneously these rules were broken up between “exactly matching expression” and “Better conversion from expression”?
The following code is disallowed by the spec, but allowed by the Microsoft 4.0 spec and the roslyn compiler.
In that version, the “Better conversion from Expression” contains this as part of the tie breakers to determine that D1 is better than D2:
That final bullet is no longer in 12.6.4.7 (better conversion target) or 12.6.4.5 (better conversion from expression). I wonder if it was dropped erroneously these rules were broken up between “exactly matching expression” and “Better conversion from expression”?
Thanks @BillWagner for digging up this reference.
The text was updated successfully, but these errors were encountered: