fixed bug: invoke overload method disorder
This commit is contained in:
@@ -114,8 +114,19 @@ class JavaMethod extends JavaMember {
|
|||||||
|
|
||||||
final JavaMethod[] methods;
|
final JavaMethod[] methods;
|
||||||
|
|
||||||
|
// no parammeter method index in overload method
|
||||||
|
int noArgMethodIndex = -1;
|
||||||
|
|
||||||
Overload(JavaMethod[] methods) {
|
Overload(JavaMethod[] methods) {
|
||||||
this.methods = methods;
|
this.methods = methods;
|
||||||
|
JavaMethod m;
|
||||||
|
for (int i=0; i<methods.length; i++) {
|
||||||
|
m = methods[i];
|
||||||
|
if (m.fixedargs.length == 0 && m.varargs == null) {
|
||||||
|
noArgMethodIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public LuaValue call() {
|
public LuaValue call() {
|
||||||
@@ -140,6 +151,10 @@ class JavaMethod extends JavaMember {
|
|||||||
|
|
||||||
private LuaValue invokeBestMethod(Object instance, Varargs args) {
|
private LuaValue invokeBestMethod(Object instance, Varargs args) {
|
||||||
JavaMethod best = null;
|
JavaMethod best = null;
|
||||||
|
int n = args.narg();
|
||||||
|
if (n == 0 && noArgMethodIndex != -1) {
|
||||||
|
best = methods[noArgMethodIndex];
|
||||||
|
} else {
|
||||||
int score = CoerceLuaToJava.SCORE_UNCOERCIBLE;
|
int score = CoerceLuaToJava.SCORE_UNCOERCIBLE;
|
||||||
for ( int i=0; i<methods.length; i++ ) {
|
for ( int i=0; i<methods.length; i++ ) {
|
||||||
int s = methods[i].score(args);
|
int s = methods[i].score(args);
|
||||||
@@ -150,6 +165,7 @@ class JavaMethod extends JavaMember {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// any match?
|
// any match?
|
||||||
if ( best == null )
|
if ( best == null )
|
||||||
|
|||||||
Reference in New Issue
Block a user