-
Notifications
You must be signed in to change notification settings - Fork 26
Method Deduction
If type is supplied, the closest type is considered first.
For integer value, if it's in int32 range, then it's assumed to be int. The rank is according to which range is closer to the value. Float type can accept integer value if no integer type found and float is considered before double.For long type below lua 5.3,a library call 'i64' is imported to represent value can't be represent by double,so long type accept i64 value also.Boxed type will be used if no primitive type found.
For float value, double has more weight than float.
For string, if the type is char and the string length is one,then ranks first,string ranks second,followed by any assignble from java.lang.String.
For nil, treated as (Type)null;
For java object, evaluating in terms of class hierarchy.Specically, if no object type found for a boxed type, primitive type will be in consideration.
For function, any functional interface is considered ok
For table, if the type is convertible from table in registered table converters,the type is considered first,or if the value have the below layout
{methodName1=function() end,methodName2=function () end,...}
and the type is a interface, then it's considered as an implementation for the interface. For a convertible type, no type can be superior to the other, so for specified class like Arrays.copyOf, where all th array types has the same weight, which method is chosen is unspecified. To clarify your intention, add a type before the table when calling a method.
Light user data is treated as integer.
Full user data is treated as null.
If the method is vararg and its info is not remove by proguard, then you can call it like java. e.g.
using java.lang
String.format("%d,%d,%d,%d",1,3,4,6)
String.format("d")
String.format("%s",'g')
--or
String.format("%d,%d,%d,%d",{1,3,4,6})
Passing a null as a vararg array is allowed, but its result is undefined. If you want to pass a table or an array as the only argument for things like Object... args, cast it to the Object first. or it will be regarded as the argument for the vararg array.