Should instances of refined types be seperate classes if refinements are limited to member types?


class Types {
	type Type
(new Types { type Type = Int }).getClass

val res0: Class[_ <: Types] = class $anon$1

It seems a bit wasteful. There could be an argument for reflection support, providing additional information, but as such a refinement can - and often is - created by an anonymous method,
the member type is defined differently with different calls. This is particularily useful with implicit definitions, where every implicit method would return a different subclass of the implicit evidence.
Considering that member types are encouraged over higher types in many cases, this, to an extent,
goes against the erasure concept applied to the latter.

You don’t even need a type member.

scala> new Foo().getClass
val res0: Class[_ <: Foo] = class Foo

scala> new Foo{}.getClass
val res1: Class[_ <: Foo] = class $anon$1

Not sure if there would be any drawback to optimizing away the anonymous classes that contain nothing but type definitions.