fixed bug: invoke overload method disorder

This commit is contained in:
UnlegitDqrk
2026-03-01 12:59:23 +01:00
parent ba3d1d8ef9
commit 068451886d

View File

@@ -114,8 +114,19 @@ class JavaMethod extends JavaMember {
final JavaMethod[] methods;
// no parammeter method index in overload method
int noArgMethodIndex = -1;
Overload(JavaMethod[] 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() {
@@ -140,6 +151,10 @@ class JavaMethod extends JavaMember {
private LuaValue invokeBestMethod(Object instance, Varargs args) {
JavaMethod best = null;
int n = args.narg();
if (n == 0 && noArgMethodIndex != -1) {
best = methods[noArgMethodIndex];
} else {
int score = CoerceLuaToJava.SCORE_UNCOERCIBLE;
for ( int i=0; i<methods.length; i++ ) {
int s = methods[i].score(args);
@@ -150,6 +165,7 @@ class JavaMethod extends JavaMember {
break;
}
}
}
// any match?
if ( best == null )