-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Use covariant return for synthesized record clone #53404
Changes from 5 commits
23f3b94
c21e7cf
54ae436
c46f7fb
173760e
e9c6c35
48ccab1
37cf2a4
c08d38d
2b0d088
3723cba
55db7da
e3c369a
d224dd2
8941ff4
85c48b7
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 |
---|---|---|
|
@@ -97,8 +97,8 @@ static bool modifiersAreValid(DeclarationModifiers modifiers) | |
|
||
protected override (TypeWithAnnotations ReturnType, ImmutableArray<ParameterSymbol> Parameters, bool IsVararg, ImmutableArray<TypeParameterConstraintClause> DeclaredConstraintsForOverrideOrImplementation) MakeParametersAndBindReturnType(BindingDiagnosticBag diagnostics) | ||
{ | ||
return (ReturnType: VirtualCloneInBase() is { } baseClone ? | ||
baseClone.ReturnTypeWithAnnotations : // Use covariant returns when available | ||
return (ReturnType: VirtualCloneInBase() is { } baseClone && !ContainingAssembly.RuntimeSupportsCovariantReturnsOfClasses ? | ||
baseClone.ReturnTypeWithAnnotations : | ||
TypeWithAnnotations.Create(isNullableEnabled: true, ContainingType), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please include a test that demonstrates the change. #Closed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was expecting to see CI failures since this code path is already extensively tested. Will look and see why no tests are failing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests for records don't vary the One way to control this is to define your own tiny corlib in a test using There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more.
I prefer that we don't do this, we want to test against real frameworks and verify runtime behavior as well. Achieving that with a private tiny corlib is going to be non trivial. I think that testing both modes should be rather simple. It looks like record tests use default TargetFramework. That means that, when tests are run on desktop they are run against desktop (doesn't support covariant returns) and, when run on CoreCLR they are run against CoreCLR (supports covariant returns). We should be able to observe difference between these two modes. However, it looks like default target framework for tests on CoreClr is NetStandard20 (doesn't say that the feature will be supported at runtime), we should be able to explicitly request NetCoreApp framework. I think TargetFramework.StandardLatest would give us what we want for desktop and for CoreCLR. The expectations in the tests will have to be conditional based on the platform |
||
Parameters: ImmutableArray<ParameterSymbol>.Empty, | ||
IsVararg: false, | ||
|
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.
Consider reordering conditions. #Closed