HaxeFoundation / HaxeFoundation/haxe
Cannot create field X due to type mismatch
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
```cmd
source/Main.hx:36: characters 3-46 : error: TypedGroup.T should be SomeType
source/Main.hx:36: characters 3-46 : ... have: (Array<(TypedGroup.T, ...) -> ...>, ...) -> ...
source/Main.hx:36: characters 3-46 : ... want: (Array<(SomeType, ...) -> ...>, ...) -> ...
source/Main.hx:36: characters 3-46 : Cannot create field multiTransformChildren_Float due to type mismatch
source/Main.hx:40: characters 2-101 : ... Conflicting field was defined here
```
https://try.haxe.org/#1A868821
```haxe
class Test {
static function main() {
trace("Haxe is great!");
var myTransform = (s:SomeType, v:Float) -> {};
var g = new TypedGroup();
g.multiTransformChildren([myTransform], [10.0]);
}
}
class SomeType {
public function new() {}
}
class TypedGroup extends SomeType {
public function new() {
super();
}
public function setThings(value:Float) {
var callback = (obj:SomeType, v:Float) -> {}
multiTransformChildren([callback], [value]);
}
@:generic
public function multiTransformChildren(callbacks:ArrayV->Void>, values:Array):Void {}
}
```
Tested on 4.3.3 and 5.0.0-alpha.1+dec37b3 with the same results.
Original problem was found in flixel, so maybe it is not the Haxe but how flixel is used - if I remove `generic` from `multiTransformChildren` then it compiles. Maybe #10635 is related.
Contributor guide
Assessment
This issue has not been assessed yet.