Specialize generic constraint with abstract


(Adrian V) #1

why is it not possible to specialize a generic type parameter constraint with an abstract

cheers Adrian.

(Juraj Kirchheim) #2

Abstracts generally don’t unify with anonymous types: (unless the underlying type does).

(Adrian V) #3

Ok now I see where it comes from. Thanks

(Adrian V) #4

thinking a bit about this issue. In a normal context this makes sense because abstracts don’t exist at runtime as a type. But when a class marked with @:generic it should be possible since for each specialization an own class is generated.
This would be really nice. For example it is not possible to write a generic class which works on Vector or Array because Vector is an abstract.

(Juraj Kirchheim) #5

I absolutely agree and I have proposed this a few years ago to no awail:

But perhaps now is a good time to ask again :wink:

(Adrian V) #6

Maybe I should create a proposal on haxe-evolution for this