Skip to content

Support for var in record patterns#1312

Merged
bulldozer-bot[bot] merged 5 commits into
palantir:developfrom
emandirola:support-var-in-record-patterns
Jun 9, 2025
Merged

Support for var in record patterns#1312
bulldozer-bot[bot] merged 5 commits into
palantir:developfrom
emandirola:support-var-in-record-patterns

Conversation

@emandirola
Copy link
Copy Markdown
Contributor

Before this PR

palantir fails when parsing source files with var inside a record pattern.
e.g.

if (o instanceof Record(var i)) {}
switch (o) {
  case Record(var i):
}

After this PR

Added support for var in record patterns.
The AST explicitly unsets the type when it sees var.
We may assume that's the reason type is null, so we just output "var".
Fixes #1309

Possible downsides?

The type is set to null when the token found is var, might change in the future?
There's a declaredUsingVar but it's false, might be broken (including java 24)

The AST explicitly unsets the type when it sees `var`.
We may assume that's the reason `type` is `null`, so we just output "var".
@changelog-app
Copy link
Copy Markdown

changelog-app Bot commented Jun 4, 2025

Generate changelog in changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

Support for var in record patterns

Check the box to generate changelog(s)

  • Generate changelog entry

@CRogers
Copy link
Copy Markdown
Contributor

CRogers commented Jun 9, 2025

👍

1 similar comment
@felixdesouza
Copy link
Copy Markdown

👍

@bulldozer-bot bulldozer-bot Bot merged commit 21a7177 into palantir:develop Jun 9, 2025
7 checks passed
@autorelease3
Copy link
Copy Markdown

autorelease3 Bot commented Jun 9, 2025

Released 2.68.0

@emandirola emandirola deleted the support-var-in-record-patterns branch September 23, 2025 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Record patterns should be supported

3 participants