public class Temp {
public void foo() {
// uses int overload, ok
int a = f(1, 2);
// uses int overload, again ok
int b = f(1, (short)2);
// uses float overload (and shows "cannot cast float to int" error): WRONG, should still use int overload
int c = f((short) 1, (short)2);
}
public static float f(float a, float b) {
return a + b;
}
public static int f(int a, int b) {
return a + b;
}
}
In all three cases the f(int a, int b) overload is selected by compiler (because int is better conversion target from short than float).
But Consulo makes the wrong decision: in third case it decides to use f(float, float) overload (it is easy to check this by ctrl+clicking on method call) and this causes it to think that the assignment of the result to c is error:
But this is not correct: the given piece of code compiles without warnings.
P.S. actually I noticed this issue with the given piece of code:
int random = UnityEngine.Random.Range(short.MaxValue/2, short.MaxValue);
It is similar because Random.Range indeed has two overloads: one for (int,int)->int and one for (float,float)->float. But as you see above, the issue is not relevant for Consulo's Unity integration, that's why I'm reporting it here.
Consider the following code:
In all three cases the
f(int a, int b)
overload is selected by compiler (becauseint
is better conversion target fromshort
thanfloat
).But Consulo makes the wrong decision: in third case it decides to use
f(float, float)
overload (it is easy to check this by ctrl+clicking on method call) and this causes it to think that the assignment of the result toc
is error: But this is not correct: the given piece of code compiles without warnings.P.S. actually I noticed this issue with the given piece of code:
It is similar because
Random.Range
indeed has two overloads: one for(int,int)->int
and one for(float,float)->float
. But as you see above, the issue is not relevant for Consulo's Unity integration, that's why I'm reporting it here.