12.6.7.3 CPP0002 - Native Marshalling Types and Function Closures

Description

Member functions of extern classes annotated with :cpp.ValueType or :cpp.PointerType can only be directly invoked, attempting to create closures from these member functions will generate this error.

Examples

The following examples generate CPP0002.

@:semantics(value)
@:cpp.ValueType
extern class Foo {
    function new():Void;

    function bar():Void;
}

function main() {
    final f = new Foo();
    final c = f.bar; // CPP0002

    c();
}
@:semantics(value)
@:cpp.PointerType
extern class Foo {
    static function allocate():Foo;
    function bar():Void;
}

function main() {
    final f = Foo.allocate();
    final c = f.bar; // CPP0002

    c();
}