Record anonymous type dependencies during initial binding#81024
Record anonymous type dependencies during initial binding#81024AlekseyTs merged 2 commits intodotnet:mainfrom
Conversation
|
@dotnet/roslyn-compiler Please review |
1 similar comment
|
@dotnet/roslyn-compiler Please review |
| public bool ReportMissingOrErroneousSymbolsForDelegates(BindingDiagnosticBag diagnostics) | ||
| { | ||
| // If we start reporting errors for non-Special types or members here, | ||
| // we need to call this method from ConstructAnonymousDelegateSymbol to callect dependencies. |
There was a problem hiding this comment.
| // we need to call this method from ConstructAnonymousDelegateSymbol to callect dependencies. | |
| // we need to call this method from ConstructAnonymousDelegateSymbol to collect dependencies. | |
| ``` #Resolved |
| { | ||
| if (diagnostics.AccumulatesDependencies) | ||
| { | ||
| var depencies = BindingDiagnosticBag.GetInstance(withDependencies: true, withDiagnostics: false); |
There was a problem hiding this comment.
| var depencies = BindingDiagnosticBag.GetInstance(withDependencies: true, withDiagnostics: false); | |
| var dependencies = BindingDiagnosticBag.GetInstance(withDependencies: true, withDiagnostics: false); | |
| ``` #Resolved |
| /// Given anonymous type descriptor provided constructs an anonymous type symbol. | ||
| /// </summary> | ||
| public NamedTypeSymbol ConstructAnonymousTypeSymbol(AnonymousTypeDescriptor typeDescr) | ||
| public NamedTypeSymbol ConstructAnonymousTypeSymbol(AnonymousTypeDescriptor typeDescr, BindingDiagnosticBag diagnostics) |
There was a problem hiding this comment.
Consider renaming diagnostics or adding a doc comment, so it's clearer at the callsites that it's only used to collect dependencies (and hence why it's fine to pass BindingDiagnosticBag.Discarded sometimes) #Resolved
There was a problem hiding this comment.
Consider renaming
diagnosticsor adding a doc comment, so it's clearer at the callsites that it's only used to collect dependencies (and hence why it's fine to passBindingDiagnosticBag.Discardedsometimes)
That is not the reason why it is fine to pass BindingDiagnosticBag.Discarded. In fact, that would be a wrong reason to do that. Also, it is fine to pass BindingDiagnosticBag.Discarded to pretty much any function that takes a BindingDiagnosticBag when there is no intent to use the information that might be collected, except those that are going to crash because they use DiagniosticBag directly (we have a small amount of functions like that). Why we might have no intent to use the information depends on each specific situation. However, in general, if we intend to preserve diagnostics, we usually should preserve dependencies as well. Also, there would be nothing wrong for this function to report a diagnostic if we decide that it is beneficials. Callers should make no assumption about what is being reported inside. At the moment, we don't report any diagnostics here, because all of it will be reported when we attempt to emit anyway. Reporting it here as well is going to produce a lot of duplicate errors.
|
|
||
| Public Function ReportMissingOrErroneousSymbols(diagnostics As BindingDiagnosticBag, hasClass As Boolean, hasDelegate As Boolean, hasKeys As Boolean) As Boolean | ||
| ' If we start reporting errors for non-Special types or members here when hasClass is false, | ||
| ' we need to call this method from ConstructAnonymousDelegateSymbol to callect dependencies. |
There was a problem hiding this comment.
| ' we need to call this method from ConstructAnonymousDelegateSymbol to callect dependencies. | |
| ' we need to call this method from ConstructAnonymousDelegateSymbol to collect dependencies. | |
| ``` #Resolved |
|
@dotnet/roslyn-compiler For a second review |
1 similar comment
|
@dotnet/roslyn-compiler For a second review |
Fixes #73558