Extern inline override signature

Hej !

How can I kind of “override” a function in an extern class please ?
Let say I have that, initially the function wants a NativeArray but I want to pass it a Haxe Array which I converts then into NativeArray … :

public inline function setFoo( a : Array<String> ) : Void {
#if php
		setFoo( php.Lib.toPhpArray( a ) );
#end
	}

overload extern inline function setFoo(...

Thanks Aleksandr,

overload extern inline function setFoo( a : Array<String> ) : Void{
#if php
	setFoo( php.Lib.toPhpArray( a ) );
#end
}

I still get : php.NativeArray should be Array<String>

Ok my bad, I think I haven’t understand well how overload works…
So is it the right way to do that please ? :

overload public function setFoo( a : php.NativeArray ) : Void;
overload inline function setFoo( a : Array<String> ) : Void{
#if php
	setFoo( php.Lib.toPhpArray( a ) );
#end
}

Yes, but you have to add extern accessor to the second overload.

My whole class is marked with @:extern

All overloads of a same function need to be overload extern inline, not only the new one. I suppose you can indeed skip the extern keyword in an extern class, but not the inline keyword.

This should work for your use case:

@:noCompletion @:native('setFoo') function _setFoo(a:php.NativeArray):Void;

overload inline function setFoo(a:php.NativeArray):Void _setFoo(a);
overload inline function setFoo(a:Array<String>):Void {
  #if php _setFoo(php.Lib.toPhpArray(a)); #end
}

(not sure how the #if php is useful since it’s overloading a function using php.NativeArray as argument…)

Hej Rudy !

Thanks for your reply.

But I can confirm you that it works as I wrote (so the native one without inline keyword…), I’ll rewrite it as it is in my code and I’ve just tested it like that (it takes the right overload function with 2 different arguments…) :

@:native('Google_Client')
extern class Client {
	public function new():Void;
	public function useApplicationDefaultCredentials( ?b : Bool ):Void;
	public function getConfig( s : String ) : Dynamic;
	overload public function setScopes( a : php.NativeArray ) : Void;
	overload inline function setScopes( a : Array<String> ) : Void{
#if php
		setScopes( php.Lib.toPhpArray( a ) );
#end
	}
	public function addScope( e : String ):Void;
	public function setSubject( s : String ):Void;
	public function setDefer( b : Bool ):Void;
...
}