Forbid types with required members from substituting for where T : new()#60788
Forbid types with required members from substituting for where T : new()#60788333fred merged 5 commits intodotnet:features/required-membersfrom
Conversation
|
@jcouv @RikkiGibson for review. |
src/Compilers/CSharp/Test/Symbol/Symbols/RequiredMembersTests.cs
Outdated
Show resolved
Hide resolved
|
|
||
| void M1<T>() where T : struct | ||
| { | ||
| M2<T>(); |
There was a problem hiding this comment.
Could we someday:
- add a warning wave for this call here, then
- add the ability to specify
where T : struct, new()to suppress the warning, then - add a diagnostic onto
M1<C>()(would probably need to be a warning?)
There was a problem hiding this comment.
No idea. I would love to, but no idea.
| } | ||
| } | ||
| return synthesizedIfMissing; | ||
| return synthesizedIfMissing && !hasAnyRequiredMembers; |
There was a problem hiding this comment.
It seems like we're making the assumption that the synthesized parameterless constructor will never have 'HasSetsRequiredMembers'. Is that fine?
There was a problem hiding this comment.
I can't see how it wouldn't be.
This method should be renamed (maybe "SatisfiesParameterlessConstructor"?) and doc comment updated. In reply to: 1109109969 Refers to: src/Compilers/CSharp/Portable/Symbols/ConstraintsHelper.cs:1377 in aac7cbe. [](commit_id = aac7cbe, deletion_comment = False) |
jcouv
left a comment
There was a problem hiding this comment.
Done with review pass (iteration 1)
|
@jcouv @RikkiGibson please take another look. |
…o forbid-new * upstream/features/required-members: (156 commits) Pass fallback options (dotnet#60803) Rename `CodeStyleHostLanguageServices.cs.cs` to `CodeStyleHostLanguageServices.cs` (dotnet#60955) Allow VSMac to access LSP options (dotnet#60943) Add configs for 17.3 branch and update main version (dotnet#60942) Restore nugetKind config to publish data Remove unnecessary publish data config Remove non-servicing 15.x publish config Let 'arcade' packageFeeds imply all feeds are 'arcade' Remove non-servicing branches from our PublishData Handle unexpected keyword rather than identifier for lambda parameter name (dotnet#60825) Correctly return E_NOTIMPL when asked for file code models for non-source Move the resources to top (dotnet#60899) Add back deprecated packages to arcade publishing config. Simplify Rename parameter Simplify visibility logic in tagger Simplify visibility logic in tagger Try out some fixes Update StructConstructorTests.cs Use more descriptive variable name ...
Specification: https://github.com/dotnet/csharplang/blob/main/proposals/required-members.md
Test plan: #57046