Skip to content

Java front end, Kotlin printer: an inner class of a generic class keeps the outer type arguments - #154

Closed
tomtourwe wants to merge 1 commit into
develfrom
fix/kotlin-inner-of-generic-type-arguments
Closed

tomtourwe wants to merge 1 commit into
develfrom
fix/kotlin-inner-of-generic-type-arguments

Conversation

@tomtourwe

Copy link
Copy Markdown

What

A parameter typed G<String>.In was parsed with no type arguments: ClassSymbolScanner read only
In's own (none), not javac's enclosing type G<String>. The Kotlin printer then wrote
a.Top.G.In, which kotlinc rejects (one type argument expected).

The front end now puts the enclosing type's arguments first, as the bytecode reader already does
for such types; KotlinTypeName prints each class's arguments on that class.
Now: x: G<String>.In. All maddi tests pass with this change.
Test: TestJavaToKotlinStructure.innerOfGenericClassNamedOutsideIt (output 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

…ps the outer type arguments

A parameter typed `G<String>.In` was parsed with no type arguments: ClassSymbolScanner read only
In's own (none), not javac's enclosing type `G<String>`. The Kotlin printer then wrote
`a.Top.G.In`, which kotlinc rejects (one type argument expected).

The front end now puts the enclosing type's arguments first, as the bytecode reader already does
for such types; KotlinTypeName prints each class's arguments on that class.
Now: `x: G<String>.In`. All maddi tests pass with this change.
Test: TestJavaToKotlinStructure.innerOfGenericClassNamedOutsideIt (output 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: b8a227d.

  • Conflict: KotlinTypeName.base had changed on devel. innerWithOuterArguments is inserted after the parameters().isEmpty() return, as in your branch. The ClassSymbolScanner change applied as is.
  • Interaction with devel: once the front end puts the outer's type arguments first in parameters(), a devel change printed an inner superclass with all of them. For example, Base<E>.EntrySet<E>.EntrySet() appeared in TestJavaToKotlinStructure. A follow-up commit, cabd036, keeps only the class's own type arguments in KotlinTypePrinter.sameNamedInnerSuperclass and innerOfAGenericOuter. Nothing else needed changing.

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