HaxeFoundation / HaxeFoundation/haxe

Map with parameterized key

Open
#9,023 1 comment 0 reactions 0 assignees View on GitHub
feature-abstracts
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

```haxe
@:generic
class MyMap {
public var map: Map = new Map();
public function new() {}
}
```
This code does not compile with error

>Abstract haxe.ds.Map has no @:to function that accepts haxe.IMap

I always thought that this is because underlying type selection occurs before type parameter application. But this is not the case, because I've just discovered that `@:remove` metadata makes this example compile. So now I'm confused, why it does not just work with `@:generic` only.
Also this is not documented in any way, I've only found this mentioned here: https://github.com/HaxeFoundation/haxe/issues/2537

Also it does not help with abstracts. It actually looks like abstracts cannot be generic at all...
```haxe
@:generic @:remove
abstract MyMap(Map) {
public function new() {
this = new Map();
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.