Skip to content

#1519 Avoid unused delegate field in decorators - #4099

Open
kalayciburak wants to merge 1 commit into
mapstruct:mainfrom
kalayciburak:fix/1519-unused-delegate-field
Open

#1519 Avoid unused delegate field in decorators#4099
kalayciburak wants to merge 1 commit into
mapstruct:mainfrom
kalayciburak:fix/1519-unused-delegate-field

Conversation

@kalayciburak

@kalayciburak kalayciburak commented Jul 19, 2026

Copy link
Copy Markdown

Fixes #1519.

This avoids generating the private delegate field and its constructor assignment when the decorator implements all mapper methods itself.

Constructor generation now handles both decorator shapes:

  • A user-defined delegate constructor still receives the generated delegate through super(delegate).
  • A default-constructor decorator no longer creates an unused delegate instance or an empty private delegate constructor.

The change also avoids retaining unused mapper imports for custom implementation packages, including nested decorators, while preserving imports required by generated annotations.

Regression coverage runs with both javac and Eclipse compilers and covers delegate-constructor and default-constructor decorators. Existing partial-decorator, Spring, JSR-330/Jakarta, cross-package, and destination-package suites remain green.

Tests:

@kalayciburak
kalayciburak force-pushed the fix/1519-unused-delegate-field branch from fadcc4f to 228a68f Compare July 19, 2026 17:42
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.

Very minor suggestion: don't generate private delegate field if it's not used

1 participant