-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
explicit lambda return type behavior with covariant delegates #73319
Comments
Definitely an interesting case! Would have to see how the spec works here. but i soemwhat agree. This feels like it should fall out from lambda return types and variance. i wonder if there's some rule preventing this, or if ti's an accidental compiler bug. |
@cston is this "by design"? Not sure it's going to meet the bar for fixing right now but curious as to the intent. |
Variance is not supported for an explicit lambda return type in the anonymous function conversion: see Explicit return type.
That matches the conversion requirement for lambdas with explicitly-typed parameters: see 10.7 Anonymous function conversions.
Parameter example: see sharplab.io Action<string> a1 = (object o) => { }; // error CS1661: ... parameter types do not match
Action<object> a2 = (object o) => { }; |
I think as long as the delegate is covariant this should work since an indirect assignment of the same expression is valid.
The text was updated successfully, but these errors were encountered: