Java printer: outer.new Inner() prints as outer.new X.Inner()
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Start with the round trip the report describes: parse the snippet in the issue, then call JavaInspector.print2 with Formatter2Impl. The bug is in how the printer writes the class name of a qualified instance creation (outer.new Inner(...)), so find where that expression is formatted and where the type name is qualified. Done when the snippet prints as outer.new Inner(1) and this.new Inner(2), and the output re-parses.
Written by the indexing model from the issue text.
Description
Problem
A qualified inner-class instance creation, outer.new Inner(...), is printed with the class name qualified as well. That isn't valid Java: javac reports '(' expected.
public class X {
class Inner { final int v; Inner(int v) { this.v = v; } }
static Inner make(X outer) { return outer.new Inner(1); }
Inner makeThis() { return this.new Inner(2); }
}
prints as
static X.Inner make(X outer) { return outer.new X.Inner(1); }
X.Inner makeThis() { return this.new X.Inner(2); }
Expected
After outer.new, the class is named by its simple name, relative to the outer instance's type: outer.new Inner(1), this.new Inner(2).
Seen on
A round trip (parse, then JavaInspector.print2 with Formatter2Impl) on maddi 0.9.5-alpha.5. On real code:
- picocli:
OFF.new CommandLine.Help.Ansi.Text(0)andthis.new CommandLine.Help.Ansi.Text(...)inCommandLine.java. The whole file fails to re-parse, which is almost all of picocli. - javaparser:
ParserConfiguration.this.new ParserConfiguration.UnicodeEscapeProcessor().
- Dominant language
- Java
- Stars
- 1
- Forks
- 1
- Avg merge
- 1h 58m
- Merged PRs (30d)
- 5
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from CodeLaser/maddi
-
build/ci good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
bug front-end:javac
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
C# printer: an inner class of a generic class needs the outer type's arguments (Outer<A>.Inner)Openfront-end:csharp
Difficulty 4/5 3-5 days Newbie friendliness 30/100
-
Difficulty 5/5 Over a week Newbie friendliness 10/100
-
Java → C# translation: an idiomatic C# printer driven by the modification and nullability analysesOpenenhancement extension front-end:csharp
Difficulty 5/5 Over a week Newbie friendliness 8/100
Similar issues
-
False Negative: InnerTypeLastCheck does not report members declared after inner enums or annotationsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
checkstyle/checkstyle#22027 ·
Maintainers usually reply within 1 day
-
bug follow-up lane:auto
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Sanne/incus-spawn#1497 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
[BUG][RUST] chrono date-time path/query/header params are not serialized as RFC 3339Possibly taken @teovillanueva claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
OpenAPITools/openapi-generator#25297 ·
Maintainers usually reply within 1 day
-
[CI] NettyClientTest.testServerDisconnection may fail with DisconnectExceptionPossibly taken @yangshangqing95 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day