-
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
Infer delegate types with -langversion:10 (and above) only #55232
Conversation
…otnet#53241)" (dotnet#53466)" This reverts commit 7d461ed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thanks (iteration 1)
@@ -1358,12 +1358,9 @@ static void Main() | |||
// (6,30): error CS0034: Operator '==' is ambiguous on operands of type '<null>' and 'default' | |||
// System.Console.Write((null, () => 1) == (default, default)); | |||
Diagnostic(ErrorCode.ERR_AmbigBinaryOps, "(null, () => 1) == (default, default)").WithArguments("==", "<null>", "default").WithLocation(6, 30), | |||
// (6,37): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. | |||
// (6,30): error CS0019: Operator '==' cannot be applied to operands of type 'lambda expression' and 'default' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if later on (i.e. not in this PR/release) it will be practical to devise some way to still give LangVersion diagnostics. For example, by checking again at the point we give a conversion error if a valid conversion "would have" existed in the later language version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thanks (iteration 2)
Approved to merge whenever CI is green |
Do not infer delegate types for lambda expressions and method groups when compiling with
-langversion:9
and earlier, to restore the binding behavior from C#9 for those cases.This matches the behavior in 16.11 where inferring delegate types is conditional on
-langversion
(see #53241). That behavior was reverted in commit 7d461ed for earlier 17.0 previews, and is now re-applied.See LDM notes: lambda-conversion-to-systemdelegate.