Skip to content
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

Resugar makeConcatWithConstants into string templates when supported #377

Open
Gaming32 opened this issue Apr 18, 2024 · 1 comment
Open
Labels
enhancement New feature or request Priority: Low Low priority Subsystem: Writing Anything concerning how expressions are written

Comments

@Gaming32
Copy link

Is your feature request related to a problem? Please describe.

String templates currently will decompile into the string concats they're desugared into.

Describe the solution you'd like

If the class file supports string templates (currently Java 21+ preview class files), these string concats could be sugared into string templates. It's not guaranteed they were originally string templates, but it's impossible to tell if they were (the desugaring happens on the AST, so javac literally compiles them as if they were standard string concats).

Additional context

Original source
public class Bar {
    void foo(int x) {
        System.out.println(STR."foo: \{x}");
    }

    void bar(int x) {
        System.out.println(STR."bar: \{x}");
    }
}
Decompiled source (Vineflower 1.10.1)
public class Bar {
   void foo(int x) {
      System.out.println("foo: " + x);
   }

   void bar(int x) {
      System.out.println("bar: " + x);
   }
}
@Gaming32 Gaming32 added the enhancement New feature or request label Apr 18, 2024
@jaskarth jaskarth added Subsystem: Writing Anything concerning how expressions are written Priority: Low Low priority labels Apr 19, 2024
@jaskarth
Copy link
Member

I think the idea was to take a look at this after the preview phase is done, as the design of string templates is still being iterated on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Priority: Low Low priority Subsystem: Writing Anything concerning how expressions are written
Projects
None yet
Development

No branches or pull requests

2 participants