Put distance variable to better use in areParametersCompatible() to fix
ambiguity in StringBuffer methods.
This commit is contained in:
parent
41a29eba7a
commit
e387788b36
1 changed files with 11 additions and 4 deletions
|
@ -410,15 +410,21 @@ public abstract class ESLoader extends ESObject {
|
||||||
// The simplest case is direct object compatibility
|
// The simplest case is direct object compatibility
|
||||||
sourceClass = params[i].getClass();
|
sourceClass = params[i].getClass();
|
||||||
accepted = targetClass.isAssignableFrom(sourceClass);
|
accepted = targetClass.isAssignableFrom(sourceClass);
|
||||||
|
if (targetClass != sourceClass) {
|
||||||
|
if (targetClass == Object.class)
|
||||||
|
distance += 2;
|
||||||
|
else
|
||||||
|
distance += 1;
|
||||||
|
}
|
||||||
debugInfo = " accepted (subclassing)";
|
debugInfo = " accepted (subclassing)";
|
||||||
|
|
||||||
if (!accepted) {
|
if (!accepted) {
|
||||||
// If we do not have direct object compatibility, we check various
|
// If we do not have direct object compatibility, we check various
|
||||||
// allowed conversions.
|
// allowed conversions.
|
||||||
|
|
||||||
// Handle number and number widening
|
// Handle number and number widening
|
||||||
if ((isPrimitiveNumberClass(sourceClass) ||
|
if ((isPrimitiveNumberClass(sourceClass) ||
|
||||||
sourceClass == Character.class)
|
sourceClass == Character.class)
|
||||||
&& isPrimitiveNumberClass(targetClass)) {
|
&& isPrimitiveNumberClass(targetClass)) {
|
||||||
// Can be widened ?
|
// Can be widened ?
|
||||||
int targetSize = getNumberSize(targetClass);
|
int targetSize = getNumberSize(targetClass);
|
||||||
|
@ -431,7 +437,7 @@ public abstract class ESLoader extends ESObject {
|
||||||
} else {
|
} else {
|
||||||
debugInfo = " rejected (not widening numbers)";
|
debugInfo = " rejected (not widening numbers)";
|
||||||
}
|
}
|
||||||
// Handle String of length 1 as a Char, which can be converted to a number
|
// Handle String of length 1 as a Char, which can be converted to a number
|
||||||
} else if (targetClass == Character.class
|
} else if (targetClass == Character.class
|
||||||
&& params[i] instanceof String) {
|
&& params[i] instanceof String) {
|
||||||
if (((String) params[i]).length()==1) {
|
if (((String) params[i]).length()==1) {
|
||||||
|
@ -440,6 +446,7 @@ public abstract class ESLoader extends ESObject {
|
||||||
convertToChar = new boolean[n];
|
convertToChar = new boolean[n];
|
||||||
}
|
}
|
||||||
convertToChar[i] = true;
|
convertToChar[i] = true;
|
||||||
|
distance += 1;
|
||||||
debugInfo = " accepted (String(1) as Character)";
|
debugInfo = " accepted (String(1) as Character)";
|
||||||
} else {
|
} else {
|
||||||
debugInfo = " rejected (String not of length 1)";
|
debugInfo = " rejected (String not of length 1)";
|
||||||
|
|
Loading…
Add table
Reference in a new issue