haxe icon indicating copy to clipboard operation
haxe copied to clipboard

Map with abstract key complains about mismatched types

Open EliteMasterEric opened this issue 1 year ago • 1 comments

Expected behavior

Given that JobIdentifier is an abstract, I should be able to create the following map:

static var callbackHandlers:Map<JobIdentifier, String> = new Map();

Actual behavior

However, I receive this error:

[ERROR] Test.hx:3: characters 60-69

 3 |   static var callbackHandlers:Map<JobIdentifier, String> = new Map();
   |                                                            ^^^^^^^^^
   | error: JobIdentifier should be _Test.JobIdentifierImpl
   | have: (haxe.IMap<_Test.JobIdentifierImpl, ...>) -> ...
   | want: (haxe.IMap<JobIdentifier, ...>) -> ...

Using new Map<JobIdentifier, String>() displays the same error.

Minimal reproduction

https://try.haxe.org/#b85078ba

Use case

I am using haxe-concurrent, and I trying to make a map storing data for each of a set of tasks, identified by their JobIdentifier.

EliteMasterEric avatar Jun 16 '24 02:06 EliteMasterEric

Workaround would be to add to JobIdentifierImpl to your abstract.

kLabz avatar Jun 17 '24 06:06 kLabz