Open MSGhero opened 7 years ago
interface Concrete<T>
{
public function getT():T;
}
class IntAMT {
public function new() { }
}
class GenericAMT<T> {
public function new() { }
}
@:multiType(T)
abstract AMT<T>(Concrete<T>) {
public function new();
@:to static inline function toInt<T:Int>(t:Concrete<T>) { return new IntAMT(); }
@:to static inline function toT<T>(t:Concrete<T>) { return new GenericAMT<T>(); }
}
class Test {
static function main() {
var amt = new AMT<Int>();
trace(amt); // works fine
traceOut(amt); // null on cpp
}
static function traceOut<T>(amt:AMT<T>):Void {
trace(amt);
}
}
For some reason cpp it typing traceout as
void Test_obj::traceOut( ::GenericAMT amt){
If it requires @:multiType, it's probably my bug...
The -D dump looks ok, so I'm not ready to blame you yet. Maybe something in a 'follow' somewhere.
Summary: When an abstract multitype is used as a function parameter on cpp, the generated function definition is incorrect if there's a
@:to
forT
orDynamic
, regardless of the order of@:to
s.Let's say
AMT
is an abstract multitype. If it realllly matters,Concrete
is an interface, and you can repro this usingopenfl.Vector
, which is "AMT" in my case.In the below example, within the function definition of
traceOut
inMain.cpp
,traceOut
is expecting aGenericAMT
, causing the parameter to be null when I pass in theIntAMT
. It should be expecting aConcrete
.Flipping the order of
@:to
s doesn't affect the function definition.When I remove the generic
@:to
, the function parameter becomesConcrete
, as it should be.Latest dev. Works in flash, doesn't on Windows or barebones cpp without OpenFL. I tried
(@:followWithAbstracts T)
, but that didn't do anything if it's supposed to.