Problems with TypeAlias


I ran into a problem with TypeAlias today when working on some tests using many references to constants in a class with a long name (so long that many of my lines were exceeding the KtLint length threshold).

The problem: declaring the same private TypeAlias in multiple files in the same package causes a ‘redeclaration’ warning / compiler error.

Private TypeAlias should have file-level visibility, so it shouldn’t be conflicting with other files in the same package. And using a different name for the same TypeAlias throughout the same package would negatively impact readability and code consistency, so a workaround isn’t desirable.

Also possibly related: I always notice my TypeAlias declarations being flagged as unused by the IDE, which is easy to ignore, but negatively impacts things like refactor -> rename (doesn’t rename uses).


This is a known problem that is reported as KT-24700. Please vote or star it to subscribe for updates on its status.

The second problem looks like KT-12632.