#2945 Stabilise top level imports by filiphr · Pull Request #2973 · mapstruct/mapstruct
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)