Infer Abstract class type from constructor

Would shorter syntax for Abstract inheritance be feasible?

abstract class Abstract<T>(val param: T)

class Test : Abstract("string")           
class Test : Abstract<>("string")


There are at least two reasons why we don’t have this:

  • the compiler and tooling really want to know the supertypes (with type-arguments) without having to look into expressions ("string"),
  • in cases more complex than this one the users prefer having the same information.

While the second point is somewhat a matter of taste, the first one is rather important for smooth tooling.

1 Like