12.6.7.11 CPP0010 - Unable to Resolve Type Parameter

Description

Type parameters in normal haxe objects use type erasure, but type parameters in native marshalling types represent C++ template parameters. Due to this difference a type parameter needs to be resolvable to it's concrete type, if Haxe is unable to do this, this error is generated.

To resolve this issue you should explicitly add a type hint or type check which will allow Haxe to resolve the parameter.

Examples

The following example generates CPP0010.

@:semantics(value)
@:cpp.ValueType
extern class Foo {
    function new():Void;
    function bar<T>():T;
}

function main() {
    final f = new Foo();

    trace(f.bar()); // CPP0010
}

Since trace accepts Dynamic as it's first argument there is nothing for Haxe's type inference to unify T against which results in this error. the following two examples are ways you can resolve this error.

@:semantics(value)
@:cpp.ValueType
extern class Foo {
    function new():Void;
    function bar<T>():T;
}

function main() {
    final f = new Foo();

    trace((f.bar() : Int)); // Type check to allow Haxe to resolve T with Int.
}
@:semantics(value)
@:cpp.ValueType
extern class Foo {
    function new():Void;
    function bar<T>():T;
}

function main() {
    final f = new Foo();
    final v : Int = f.bar(); // Variable with type hint to allow Haxe to resolve T with Int.

    trace(v);
}