-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Do not bail generating base type initializer in the presence of use site warnings #76347
Conversation
…ite warnings We were returning early from generating a call to the base record copy constructor initializer if use site diagnostics reported any kind of diagnostic, including warnings. This isn't good in general, but is particularly bad for warnings like CS1701, which are typically suppressed by the SDK and results in what seems like a completely clean csc invocation skipping calling the base constructor. Fixes dotnet#72357.
ae3f955
to
64bda64
Compare
@dotnet/roslyn-compiler for reviews |
@@ -7197,7 +7197,7 @@ internal bool TryPerformConstructorOverloadResolution( | |||
return succeededConsideringAccessibility; | |||
} | |||
|
|||
internal static bool ReportConstructorUseSiteDiagnostics(Location errorLocation, BindingDiagnosticBag diagnostics, bool suppressUnsupportedRequiredMembersError, in CompoundUseSiteInfo<AssemblySymbol> useSiteInfo) | |||
internal static void ReportConstructorUseSiteDiagnostics(Location errorLocation, BindingDiagnosticBag diagnostics, bool suppressUnsupportedRequiredMembersError, in CompoundUseSiteInfo<AssemblySymbol> useSiteInfo) |
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 are lots of uses of this method, but this was the only one that did something conditional. That seemed like a bad thing to keep around, so I just made the method return void
instead to prevent something like this from happening again.
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.
LGTM Thanks (iteration 1)
5c11508
to
64bda64
Compare
Done with review pass (commit 2) |
public record DerivedRecord : BaseRecord; | ||
""", assemblyName: "Derived", references: [comp1.EmitToImageReference()], targetFramework: TargetFramework.Net80); | ||
|
||
var verifier = CompileAndVerify(comp2, expectedOutput: ExecutionConditionUtil.IsCoreClr ? "False" : null, verify: Verification.FailsPEVerify); |
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.
Since this is specifically .NET 8, I don't think all mono environments would work, so I only did CoreClr
.
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.
LGTM (commit 3)
We were returning early from generating a call to the base record copy constructor initializer if use site diagnostics reported any kind of diagnostic, including warnings. This isn't good in general, but is particularly bad for warnings like CS1701, which are typically suppressed by the SDK and results in what seems like a completely clean csc invocation skipping calling the base constructor. Fixes #72357.