Conversation
| } | ||
| } | ||
|
|
||
| bool useType = !Compilation.IsFeatureEnabled(MessageID.IDS_FeatureInstanceMemberInNameof); |
There was a problem hiding this comment.
What is the behavior for the test scenarios when the feature is not enabled?
There was a problem hiding this comment.
Yes, without this we would bind always as value, not type, which would result in langversion error for IDS_FeatureInstanceMemberInNameof in C# 11 or lower, but since we pass BindingDiagnosticsBag.Discarded below, the error would be surfaced as "Unable to determine specific cause of the failure." during emit.
There was a problem hiding this comment.
In other words, without this change, the tests would fail with unexpected diagnostic "Unable to determine specific cause of the failure." in C# 11.
There was a problem hiding this comment.
the error would be surfaced as "Unable to determine specific cause of the failure." during emit.
Because?
There was a problem hiding this comment.
Because the node would have HasErrors = true, those errors wouldn't be in any diagnostics bag, but methodCompiler._globalHasErrors would be true, hitting this:
roslyn/src/Compilers/CSharp/Portable/Compiler/MethodCompiler.cs
Lines 199 to 208 in 42e9b92
|
Done with review pass (commit 1) |
| methodGroup.Flags, | ||
| methodGroup.FunctionType, | ||
| receiverOpt: ReplaceTypeOrValueReceiver(methodGroup.ReceiverOpt, useType: false, BindingDiagnosticBag.Discarded), //only change | ||
| receiverOpt: ReplaceTypeOrValueReceiver(methodGroup.ReceiverOpt, useType: useType, BindingDiagnosticBag.Discarded), //only change |
There was a problem hiding this comment.
Could you please investigate how TypeOValueReceiver was handled for the problematic scenario prior to #80978? #Closed
There was a problem hiding this comment.
I assume it remained in the tree, but was never used during emit or lowering. Is this correct?
There was a problem hiding this comment.
That is correct, BoundTypeOrValueExpression node remained in the tree.
| } | ||
| class D | ||
| { | ||
| public void M() { } |
| methodGroup.Flags, | ||
| methodGroup.FunctionType, | ||
| receiverOpt: ReplaceTypeOrValueReceiver(methodGroup.ReceiverOpt, useType: false, BindingDiagnosticBag.Discarded), //only change | ||
| receiverOpt: ReplaceTypeOrValueReceiver(methodGroup.ReceiverOpt, useType: useType, BindingDiagnosticBag.Discarded), //only change |
| methodGroup.Flags, | ||
| methodGroup.FunctionType, | ||
| receiverOpt: ReplaceTypeOrValueReceiver(methodGroup.ReceiverOpt, useType: false, BindingDiagnosticBag.Discarded), //only change | ||
| receiverOpt: ReplaceTypeOrValueReceiver(methodGroup.ReceiverOpt, useType: useType, BindingDiagnosticBag.Discarded), //only change |
There was a problem hiding this comment.
It looks like always discarding diagnostics here is fragile. We should try switching to boundArgument.HasAnyErrors ? BindingDiagnosticBag.Discarded : diagnostics. Also, please check other call sites of this helper that unconditionally discard diagnostics when we are not in an obvious error recovery mode. We might want to take a close look at those and quite possibly adjust as well. Also, please review other changes in #80978 that unconditionally discard diagnostics.
|
Done with review pass (commit 1) |
Fixes #82474.