Skip to content

Only record class can have a copy constructor.#68442

Merged
AlekseyTs merged 1 commit intodotnet:mainfrom
AlekseyTs:Issue68345
Jun 7, 2023
Merged

Only record class can have a copy constructor.#68442
AlekseyTs merged 1 commit intodotnet:mainfrom
AlekseyTs:Issue68345

Conversation

@AlekseyTs
Copy link
Copy Markdown
Contributor

@AlekseyTs AlekseyTs commented Jun 5, 2023

Fixes #68345.

Relates to #65697

@AlekseyTs AlekseyTs requested review from cston and jjonescz June 5, 2023 15:40
@AlekseyTs AlekseyTs requested a review from a team as a code owner June 5, 2023 15:40
@ghost ghost added the untriaged Issues and PRs which have not yet been triaged by a lead label Jun 5, 2023
@jcouv jcouv self-assigned this Jun 5, 2023
Copy link
Copy Markdown
Member

@jcouv jcouv left a 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)


internal static bool IsCopyConstructor(Symbol member)
{
if (member is MethodSymbol { ContainingType.IsRecordStruct: false, MethodKind: MethodKind.Constructor } method)
Copy link
Copy Markdown
Member

@jcouv jcouv Jun 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, isn't this change affecting the behavior for a copy constructor in a record struct? Looking at the spec, there is no notion of copy constructor in record structs.

Never mind, IsRecord really means IsRecordClass. #Closed

@AlekseyTs
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 2 pipeline(s).

@AlekseyTs
Copy link
Copy Markdown
Contributor Author

@cston, @jjonescz, @dotnet/roslyn-compiler Please review

@Kaifoij
Copy link
Copy Markdown

Kaifoij commented Jun 6, 2023

@Kaifoij
Copy link
Copy Markdown

Kaifoij commented Jun 6, 2023

2

@AlekseyTs AlekseyTs enabled auto-merge (squash) June 7, 2023 00:52
@AlekseyTs AlekseyTs merged commit 61853f2 into dotnet:main Jun 7, 2023
@ghost ghost added this to the Next milestone Jun 7, 2023
@RikkiGibson RikkiGibson modified the milestones: Next, 17.7 P3 Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers Feature - Primary Constructors untriaged Issues and PRs which have not yet been triaged by a lead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copy constructor should not be allowed to omit this initializer call in a type that is not a record

5 participants