Skip to content

Skip FinalClass when class has anonymous inner subclasses#886

Merged
timtebeek merged 1 commit into
mainfrom
tim/finalclass-anonymous-subclass
May 13, 2026
Merged

Skip FinalClass when class has anonymous inner subclasses#886
timtebeek merged 1 commit into
mainfrom
tim/finalclass-anonymous-subclass

Conversation

@timtebeek
Copy link
Copy Markdown
Member

@timtebeek timtebeek commented May 13, 2026

Summary

Test plan

  • ./gradlew test --tests FinalClassTest (new doNotFinalizeClassWithAnonymousSubclass plus existing scenarios)

A class with only private constructors can still be subclassed from within its own body via anonymous classes. Making such a class `final` produces uncompilable code.

Fixes #885
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite May 13, 2026
@timtebeek timtebeek marked this pull request as ready for review May 13, 2026 16:00
@timtebeek timtebeek merged commit 3f61726 into main May 13, 2026
1 check passed
@timtebeek timtebeek deleted the tim/finalclass-anonymous-subclass branch May 13, 2026 16:01
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

FinalClass adds final to classes with anonymous inner subclasses when all constructors are private

1 participant