Unexpected value conversion when using an abstract class with type param
deepcake opened this issue · 0 comments
deepcake commented
Discovered a value conversion when using an abstract class with a type param (not sure what exactly causes this behavior). If you make the dispatch
method inline, it will work as expected. <Int>
is also converted - it prints 1074069696 no matter what value is passed.
https://try.haxe.org/#2c563180
class Test {
static function main() {
var s = new Signal1<Bool>();
s.add(cb);
s.dispatch(false); // <--- Test.hx:8: true
}
static function cb(v:Bool) {
trace(v);
}
}
@:forward(length, iterator)
abstract Signal1<T>(Array<T->Void>) {
public inline function new() {
this = new Array<T->Void>();
}
public inline function add(cb:T->Void) {
this.push(cb);
}
public function dispatch(value:T) {
for (cb in this) {
cb(value);
}
}
}
Haxe 4.3.4