-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Extensions: improve diagnostics for operators #80928
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
Changes from 5 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,353 @@ | ||||||||
| // Licensed to the .NET Foundation under one or more agreements. | ||||||||
| // The .NET Foundation licenses this file to you under the MIT license. | ||||||||
| // See the LICENSE file in the project root for more information. | ||||||||
|
|
||||||||
| using System.Diagnostics; | ||||||||
| using System.Diagnostics.CodeAnalysis; | ||||||||
| using Microsoft.CodeAnalysis.CSharp.Symbols; | ||||||||
| using Microsoft.CodeAnalysis.CSharp.Syntax; | ||||||||
| using Microsoft.CodeAnalysis.PooledObjects; | ||||||||
|
|
||||||||
| namespace Microsoft.CodeAnalysis.CSharp; | ||||||||
|
|
||||||||
| internal partial class Binder | ||||||||
| { | ||||||||
| /// <summary> | ||||||||
| /// This type collects different kinds of results from operator scenarios and provides a unified way to report diagnostics. | ||||||||
| /// It collects the first non-empty result for extensions and non-extensions separately. | ||||||||
| /// This follows a similar logic to ResolveMethodGroupInternal and OverloadResolutionResult.ReportDiagnostics | ||||||||
| /// </summary> | ||||||||
| private struct OperatorResolutionForReporting | ||||||||
| { | ||||||||
| private object? _nonExtensionResult; | ||||||||
| private object? _extensionResult; | ||||||||
|
|
||||||||
| [Conditional("DEBUG")] | ||||||||
| private void AssertInvariant() | ||||||||
|
||||||||
| private void AssertInvariant() | |
| private readonly void AssertInvariant() | |
| ``` #Resolved |
Outdated
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.
| internal bool TryReportDiagnostics(SyntaxNode node, Binder binder, object leftDisplay, object? rightDisplay, BindingDiagnosticBag diagnostics) | |
| internal readonly bool TryReportDiagnostics(SyntaxNode node, Binder binder, object leftDisplay, object? rightDisplay, BindingDiagnosticBag diagnostics) | |
| ``` #Resolved |
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.
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.
Yes, for instance ReportDiagnostics_Binary_03 where we get here with only built-in operators being applicable. tryGetTwoBest discards built-in operators since we don't have a member to report them.
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.
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 went back and forth on this. I'll put fallback handling here instead, even though I don't think it's currently reachable due to how we produce operator results. It'll be more robust
Outdated
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.
| if (results.Count == 1 && results[0].member is { } inapplicableMember) | |
| if (results is [{ member: { } inapplicableMember }]) | |
| ``` #Resolved |
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.
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.
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.
Is this code path reachable?
I guess this shouldn't be a concern for this component.
Uh oh!
There was an error while loading. Please reload this page.
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.
It would be good to document what types can be stored in these fields #Closed