-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add support for java records in pattern matching #24140
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
base: main
Are you sure you want to change the base?
Conversation
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.
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) |
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.
Doesn't matter, but a little cleaner to just return Nil
here in my opinion
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.
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.
Closes #20561