Fix import generation for anonymous classes

Change order of statements to use erasure instead of narrowed type.
Anonymous classes can extend interfaces and classes with type parameters.
When generating imports we should use erasure of type instead of narrowed type.
Allow interfaces to be private.

Interfaces can actually be private in Java.
It is seldomly usefull to support abstraction barrier.