Infer delegate types with -langversion:10 (and above) only#55232
Merged
cston merged 2 commits intodotnet:release/dev17.0from Jul 29, 2021
Merged
Infer delegate types with -langversion:10 (and above) only#55232cston merged 2 commits intodotnet:release/dev17.0from
cston merged 2 commits intodotnet:release/dev17.0from
Conversation
…otnet#53241)" (dotnet#53466)" This reverts commit 7d461ed.
RikkiGibson
reviewed
Jul 29, 2021
| // 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' |
Member
There was a problem hiding this comment.
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.
RikkiGibson
approved these changes
Jul 29, 2021
Member
|
Approved to merge whenever CI is green |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Do not infer delegate types for lambda expressions and method groups when compiling with
-langversion:9and 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.