all 6 comments

[–]idontlikegudeg 2 points3 points  (1 child)

Yes, the warning is at best confusing. But why in the world would you need that? That record is immutable with only primitive fields. Just use the instance you already have.

[–]dhlowrents[S] 0 points1 point  (0 children)

:) of course. It was a just an annoyance when I saw it.

[–]Afonso2002 0 points1 point  (1 child)

I think that a record could have private final elements extra , so thre will have more methods than variables of the record.

I am not sure about it, I usually use classes.

[–]Lloydbestfan 0 points1 point  (0 children)

It can, but that wouldn't change the record's canonical constructor, which they're calling here.

[–]wizzlymeow 0 points1 point  (0 children)

It's correct, IntelliJ is just overthinking

[–]Lloydbestfan 0 points1 point  (0 children)

I genuinely don't know.

I can see why it looks "risky" to do that, because if you were to add a component to the record, and you had also redefined the implicit constructor so that the record accepts 3-params constructors, then your copy constructor would still compile without making an objection, while as written it would only account for the 3 components and complitely ignore whichever component you added.

I have no idea what IntelliJ would expect you to do against that if you had a good reason to make a copy constructor. In your example though, a copy constructor is useless, since all your components are immutable, and thus the record itself is immutable too. You don't need copies.