Skip to content

#3948 Generic types of declared type must match exactly#4059

Merged
filiphr merged 1 commit into
mapstruct:mainfrom
hduelme:issue_3948
Jun 5, 2026
Merged

#3948 Generic types of declared type must match exactly#4059
filiphr merged 1 commit into
mapstruct:mainfrom
hduelme:issue_3948

Conversation

@hduelme

@hduelme hduelme commented May 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #3948 and #3945.
The main issue was that MapStruct tries to match declared generic types even when they are not compatible. This results in an infinite loop when the type has a self-reference.

I used a modified version of the code provided in #3948 as a test case. I also manually tested the scenario using the repository linked in #3945 with local fixes applied.

Declared generics must match exactly (e.g. `Comparable<Number>` cannot match `Comparable<Long>)`. Recursive resolution of mismatched generics can cause infinite loops.
@filiphr filiphr merged commit 9512218 into mapstruct:main Jun 5, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants