better matching for overloaded methods
diff --git a/plugins/org.eclipse.dltk.javascript.core/src/org/eclipse/dltk/internal/javascript/validation/JavaScriptValidations.java b/plugins/org.eclipse.dltk.javascript.core/src/org/eclipse/dltk/internal/javascript/validation/JavaScriptValidations.java
index 466436e..7852c7a 100644
--- a/plugins/org.eclipse.dltk.javascript.core/src/org/eclipse/dltk/internal/javascript/validation/JavaScriptValidations.java
+++ b/plugins/org.eclipse.dltk.javascript.core/src/org/eclipse/dltk/internal/javascript/validation/JavaScriptValidations.java
@@ -30,7 +30,9 @@
import org.eclipse.dltk.javascript.typeinfo.model.JSType;
import org.eclipse.dltk.javascript.typeinfo.model.Member;
import org.eclipse.dltk.javascript.typeinfo.model.Method;
+import org.eclipse.dltk.javascript.typeinfo.model.Parameter;
import org.eclipse.dltk.javascript.typeinfo.model.Type;
+import org.eclipse.emf.common.util.EList;
public class JavaScriptValidations {
@@ -146,15 +148,27 @@
if (argCountMatches == null) {
argCountMatches = method;
} else {
- argCountMatches = null;
- break;
+ boolean match = false;
+ EList<Parameter> parameters = method.getParameters();
+ for (int i = 0; i < parameters.size(); i++) {
+ JSType argumentType = typeOf(arguments[i]);
+ JSType parameterType = parameters.get(i).getType();
+ // todo should we have the context here to call
+ // context.resolveTypeRef()?
+ match = JSTypeSet.normalize(parameterType)
+ .isAssignableFrom(
+ JSTypeSet.normalize(argumentType));
+ if (!match)
+ break;
+ }
+ if (match)
+ argCountMatches = method;
}
}
}
if (argCountMatches != null) {
return argCountMatches;
}
- // TODO implement additional checks
return methods.get(0);
}