Skip to content

Conversation

Florian3k
Copy link
Contributor

Closes #20561

@Florian3k Florian3k requested a review from a team as a code owner October 5, 2025 22:58
@jchyb jchyb self-assigned this Oct 6, 2025
@jchyb jchyb self-requested a review October 6, 2025 09:38
Copy link
Contributor

@jchyb jchyb left a comment

Choose a reason for hiding this comment

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

Really great work!

I have some small nitpicks/suggestions, mostly connected to the tests.

I have also left one more general comment about the JavaRecordFields addition that isn't really actionable, but I still wanted to point this out in case you or anyone else from the compiler team have any better suggestions there.

def javaRecordFields(tp: Type)(using Context): List[Name] =
tp.typeSymbol.getAnnotation(defn.JavaRecordFieldsAnnot) match
case Some(JavaRecordFieldsAnnotation(fields)) => fields.map(termName)
case _ => assert(false)
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't matter, but a little cleaner to just return Nil here in my opinion

Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally we would not need this, since we don't need that information pickled and it's only relevant for the current compilation run. We could add a property key for a tree, but that would only work for the situations where we use the JavaOutlineParser, when we read the classfiles we would not have access to a tree on which a property could be used. I see we can really only get this information out when parsing the tree, and we don't save it anywhere else, which I guess justifies the annotation here.

Copy link
Member

Choose a reason for hiding this comment

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

I'm 99.9% sure we can do without and I think it's best if we don't introduce this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would prefer to do this without adding new annotation, but I couldn't find another solution. If you have any suggestions, I'm happy to explore them.

@jchyb jchyb assigned Florian3k and unassigned jchyb Oct 6, 2025
Copy link
Contributor

@jchyb jchyb left a comment

Choose a reason for hiding this comment

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

Looks good!

Copy link
Member

@hamzaremmal hamzaremmal left a comment

Choose a reason for hiding this comment

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

This PR doesn't handle yet the following case:

record Foo(Object... x) {}

where we should have an unapplySeq generated.

Copy link
Member

Choose a reason for hiding this comment

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

I'm 99.9% sure we can do without and I think it's best if we don't introduce this.

@He-Pin
Copy link
Contributor

He-Pin commented Oct 10, 2025

Can we have Scala's case class be a record too? seems we can't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scala Pattern Matching on Java Records (JEP-440)
4 participants