Skip to content

Add support for var variable declarations#3821

Merged
wadoon merged 3 commits into
mainfrom
ty-inference
Jun 13, 2026
Merged

Add support for var variable declarations#3821
wadoon merged 3 commits into
mainfrom
ty-inference

Conversation

@Drodt

@Drodt Drodt commented Jun 10, 2026

Copy link
Copy Markdown
Member

Intended Change

Allows parsing of declarations with type inference, e.g.:

var x = 0;

These declarations are converted to declarations with explicit types. The declaration above is translated to

int x = 0;

This change required adding the Java10PostProcessor to our JavaParser instances. No additional taclets are necessary.

Type of pull request

  • New feature (non-breaking change which adds functionality)
  • There are changes to the (Java) code

Ensuring quality

  • I made sure that introduced/changed code is well documented (javadoc and inline comments).
  • I made sure that new/changed end-user features are well documented (https://github.com/KeYProject/key-docs).
  • I added new test case(s) for new functionality.

Additional information and contact(s)

The contributions within this pull request are licensed under GPLv2 (only) for inclusion in KeY.

@Drodt Drodt added Feature New feature or request Java Parser Java Pull requests that update Java code labels Jun 10, 2026
@wadoon

wadoon commented Jun 11, 2026

Copy link
Copy Markdown
Member

Did you also test it with referenced types? Parameterized types are currently out of reach.

The hardest thing should be: var x = b ? new String() : 2

@Drodt

Drodt commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

That example leads to an UnsupportedOperationException in JavaParser.

@wadoon wadoon self-requested a review June 13, 2026 14:13
@wadoon wadoon added this pull request to the merge queue Jun 13, 2026
Merged via the queue into main with commit c3a6418 Jun 13, 2026
36 checks passed
@wadoon wadoon deleted the ty-inference branch June 13, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature New feature or request Java Parser Java Pull requests that update Java code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants