Better detection of map type parameters #229
Merged
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.
This PR is a fix for #228.
As far as I can tell, the
mapClassgetting passed in is never aParameterizedTypesoPropertyMapResolver#getMapGenericTypealways returnsObject::class.java(and even if it was generic, the code is looking at the type parameters on the wrong class). This leads to the limitation documented here:This PR attempts to fix the issue by using ClassMate to introspect the Map type parameters. This fixes the issue described in #228 and makes map resolvers work without the need to add to the dictionary.
However, this PR doesn't fix the issue with
mapClasslosing it's generics. This means that the return type of your method can't be Map, otherwise you'll get the previous behavior of detectingObject::class.java(to be safe, the return type shouldn't be generic at all). For example, this code gets detected properly and doesn't need to use the dictionary:However this code would detect
Object::class.javaand need to still use the dictionary: