Closed Simn closed 5 years ago
Actually maybe 2. shouldn't be an option. If the type is NativeArray<Int>
(explicit or implicit), it should not silently become a reference array.
I can't be arsed to write a manual detection for this. If you use native arrays you better know what you're doing, and if you don't you should at least not complain about getting ClassCastExceptions at run-time.
We currently always create java.NativeArray (should move that btw...) as a reference type and wrap the values, mostly because "that's easy". We should use the array specializations for basic types here and generate the instructions accordingly.
The problem with this is that Haxe's type system is retarded and allow this kind of stuff:
I think we have three options:
@:absolutelyNoVariance
metadata in Haxe core which does not allow this. That's somewhat straightforward for the assignment toDynamic
, but could be a huge mess for type parameters. I think we would basically have to disable type inference for this, like for the old@:generic
implementation.We'll start with 3 either way, but the question is how much nicer we can/should make this and with what priority...