Specialize generic constraint with abstract

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

cheers Adrian.

Abstracts generally don’t unify with anonymous types: http://try-haxe.mrcdk.com/#c36e2 (unless the underlying type does).

Ok now I see where it comes from. Thanks

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.

I absolutely agree and I have proposed this a few years ago to no awail: Allow object constraints on @:generic to work with abstracts · Issue #4392 · HaxeFoundation/haxe · GitHub

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

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

2 Likes