Ensure that modreq(InAttribute) is emitted for synthesized ref readonly returning methods#80893
Ensure that modreq(InAttribute) is emitted for synthesized ref readonly returning methods#80893AlekseyTs merged 3 commits intodotnet:mainfrom
modreq(InAttribute) is emitted for synthesized ref readonly returning methods#80893Conversation
…donly` returning methods Closes dotnet#76847
|
@dotnet/roslyn-compiler For a second review |
1 similar comment
|
@dotnet/roslyn-compiler For a second review |
| comp.VerifyDiagnostics( | ||
| // (5,20): warning CS0649: Field 'var.o' is never assigned to, and will always have its default value null | ||
| // internal other o; | ||
| Diagnostic(ErrorCode.WRN_UnassignedInternalField, "o").WithArguments("var.o", "null").WithLocation(5, 20), |
There was a problem hiding this comment.
It's not obvious how this change in diagnostic output results from the change. Is this change expected? #Closed
There was a problem hiding this comment.
It's not obvious how this change in diagnostic output results from the change. Is this change expected?
It is cased by changes in Binder_Statements.cs, we no longer treat body of ref var () => throw null as returning a reference to an instance of "@var" type. Therefore, we don't treat it as a possible write to the field.
There was a problem hiding this comment.
The behavior is consistent with explicit return statements
| var delegateType = expr.GetFunctionType()?.GetInternalDelegateType(); | ||
| delegateType?.AddUseSiteInfo(ref useSiteInfo); | ||
|
|
||
| if (expr is BoundMethodGroup { Methods: not [{ MethodKind: MethodKind.LocalFunction }] } && |
There was a problem hiding this comment.
Is this check for MethodKind just to avoid cascading diagnostics (ie. checking the InAttribute both on the local function declaration and again on the usage)?
nit: If so, consider leaving a comment #Resolved
Closes #76847