-
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
Add support for nominal records #44774
Conversation
hasInstanceConstructor = true; | ||
hasParameterlessInstanceConstructor = hasParameterlessInstanceConstructor || method.ParameterCount == 0; | ||
// Ignore the record copy constructor | ||
if (!(method is SynthesizedRecordCopyCtor)) |
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.
Can we check 'method.IsImplicitlyDeclared' here instead?
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.
That's true for all SynthesizedInstanceMethodSymbols, including the record primary constructor, unfortunately
{ | ||
var comp = CreateCompilation(@" | ||
#nullable enable | ||
data class C |
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.
Please add a test for data class C()
. From your PR description, I'm not sure what is expected (allowed or not?)
Update: I see that is covered in EmptyRecord
in the other test file. #Closed
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.
Right the absence of a record parameter list is not the same as an empty record parameter list. Right now it's an error.
// PROTOTYPE: need to check base members as well | ||
var memberSignatures = s_duplicateMemberSignatureDictionary.Allocate(); | ||
foreach (var member in members) | ||
{ | ||
memberSignatures.Add(member, member); | ||
} | ||
|
||
var ctor = addCtor(paramList); | ||
// Positional record |
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.
Positional record [](start = 15, length = 17)
nit: positional members?
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)
Removes the requirement for a record to have a parameter list