Skip to content

method_dyn missing when using @:unreflective and @:nativeGen with listener callback #12437

Description

@barisyild

This issue happens when @:unreflective is used on the class and a method reference is passed to addEventListener().
The generated C++ still tries to call method_dyn, so compilation fails.

Removing @:unreflective makes the code compile, so the error only occurs when the annotation is present.

Same issue also happens with @:nativeGen

Minimal reproducible example

package;

@:unreflective
class Main {
	public static function main():Void {
		addEventListener("aaa", method);
	}
	
	public static function method(a:String):Void {
		trace(a);
	}
	
	public static function addEventListener<T>(type:String, listener:T->Void, useCapture:Bool = false, priority:Int = 0, useWeakReference:Bool = false):Void
	{
		trace(type, listener, useCapture, priority, useWeakReference);
	}
}

Compilation output

Error: Main.cpp
./src/Main.cpp(34): error C2039: 'method_dyn': is not a member of 'Main_obj'
include\Main.h(13): note: see declaration of 'Main_obj'
./src/Main.cpp(34): error C3861: 'method_dyn': identifier not found

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions