Skip to content

Conversation

@filiphr
Copy link
Member

@filiphr filiphr commented Aug 21, 2022

Make sure that GeneratedType always gets the imported types
from a Type before adding them

Fixes #2945
Fixes #2907

Make sure that GeneratedType always gets the imported types
from a Type before adding them
Copy link
Contributor

@sjaakd sjaakd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question

}

if ( needsImportDeclaration( typeToAdd ) ) {
collection.add( typeToAdd );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok.. how could this work in the first place? Now we don't add typeToAdd itself, but the required imported types..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a look at the Type implementation. We are a bit smart there when we need to do an import and only use the TopLevel.Nested for nested. There is a complex logic for computing whether we need to import a type or not.

When I did the initial work for this I changed a lot of places where we were adding types to actually return Type#getImportedTypes, but apparently this is not everywhere (considering the bug reports we've been receiving)

@filiphr filiphr merged commit 42500ca into mapstruct:main Aug 24, 2022
@filiphr filiphr deleted the 2945 branch August 24, 2022 17:38
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.

Missing import in generated mapper when referencing a nested enum from an unrelated class Unused import warning of nested classes

2 participants