When passing a bare class reference identifier (e.g., Foo) directly into a function parameter typed as an abstract enum wrapper OneOf<String, Class<Any>> @:from should return Right. But instead compiler throws Class<Foo> should be OneOf<String, Class<Any>>.
No error if class is stored in a typed variable.
https://try.haxe.org/#E9de3B35
import haxe.ds.Either;
class Test {
static function main() {
// works
test('hi');
// works
var c:Class<Foo> = Foo;
test(c);
// doesnt work
test(Foo);
// works
test(cast Right(Foo));
}
static function test(val:OneOf<String, Class<Any>>) {}
}
class Foo {}
abstract OneOf<A, B>(Either<A, B>) from Either<A, B> to Either<A, B> {
@:from inline static function fromA<A, B>(a:A):OneOf<A, B> {
return Left(a);
}
@:from inline static function fromB<A, B>(b:B):OneOf<A, B> {
return Right(b);
}
}
[ERROR] Test.hx:13: characters 8-11
13 | test(Foo);
| ^^^
| Class<Foo> should be OneOf<String, Class<Any>>
| For function argument 'val'
When passing a bare class reference identifier (e.g.,
Foo) directly into a function parameter typed as an abstract enum wrapperOneOf<String, Class<Any>>@:fromshould returnRight. But instead compiler throwsClass<Foo> should be OneOf<String, Class<Any>>.No error if class is stored in a typed variable.
https://try.haxe.org/#E9de3B35