Skip to content

Kotlin printer: g.new In() prints as g.In() - #155

Closed
tomtourwe wants to merge 1 commit into
develfrom
fix/kotlin-qualified-new-inner
Closed

tomtourwe wants to merge 1 commit into
develfrom
fix/kotlin-qualified-new-inner

Conversation

@tomtourwe

Copy link
Copy Markdown

What

g.new In() printed g.a.Top.G.In(), and a.new In() for a non-generic outer class
a.Top2.A.In(); kotlinc: unresolved reference. Only a construction without a written outer
instance was reduced to the simple name; Kotlin accepts only the simple name after outer..

Now: g.In() and a.In().
Test: TestJavaToKotlinStructure.innerClassConstructedOutsideItsOuterClass (compiles with kotlinc).

How it was found

A mutation-testing run (PIT) over the lines that maddi's latest 100 commits changed listed the changed code no
existing test checks. Tests written for those lines, from what each commit says the code should do, exposed this
bug while writing tests for 630290f; the bug is older than that commit.

Tests

On devel 07b926b: the new test fails without the fix and passes with it.
With this fix and the nine others of this series applied together, every maddi test passes
(run on 7bc974b: 2,743 tests, 0 failures).

🤖 Generated with Claude Code

`g.new In()` printed `g.a.Top.G.In()`, and `a.new In()` for a non-generic outer class
`a.Top2.A.In()`; kotlinc: unresolved reference. Only a construction without a written outer
instance was reduced to the simple name; Kotlin accepts only the simple name after `outer.`.

Now: `g.In()` and `a.In()`.
Test: TestJavaToKotlinStructure.innerClassConstructedOutsideItsOuterClass (compiles with kotlinc).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tom Tourwe <Tom.Tourwe@codelaser.io>
@bnaudts

bnaudts commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Incorporated into maddi as a cherry-pick with you as author, rather than merged from this branch. Closing this PR in favour of that commit. Commit: cfbb610.

In constructorCall, devel had meanwhile started to print the declared type arguments when translating Java (KotlinTypePrinter.declaredArguments(type)). I kept that line and applied your inner-class shortening to its result. Your implicitOuter is now called simpleInner, because it also applies to an outer that is written out, and has an added javadoc line.

The whole batch (#146–#155) passes the Kotlin, C#, printer, front-end, inspection and bytecode suites on JDK 26 and JDK 27. It goes into devel with the next merge of the ws/maddi-bug branch.

🤖 Generated with Claude Code

@bnaudts bnaudts closed this Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants