#3960 Ignore deprecated constructors when selecting a constructor - #4127
Open
obabichevjb wants to merge 1 commit into
Open
obabichevjb wants to merge 1 commit into
obabichevjb wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Here is the fix of the issue Mapstruct not working with Kotlin/Kapt 2.3.0-RC #3960
The main part of the fix - ignoring of deprecated constructors (which could be created by
plugin.jpafor example).plugin.jpaadds a hidden no-arg constructor, because JPA requires one. Until Kotlin 2.3.0 a bug (KT-53122)left that constructor out of the KAPT stubs, so MapStruct never saw it. Kotlin 2.3.0 fixed the bug — and now MapStruct
sees two constructors:
@Deprecated public MyClass () { }generated for JPA andpublic MyClass (String id, String name, String password)the real one.MapStruct's rule was "if a parameterless constructor exists, use it and ignore the others." So it picked the generated
one, then tried to fill the object with setters — of which there are none. Result: nothing could be written.
The fix allows to ignore generated constructor. Which is marked deprecated in Kotlin
@Deprecated (level = HIDDEN).Two safety valves: if every constructor is deprecated they're all kept (otherwise the type couldn't be built at all),
and an explicit
@Defaultstill wins.