V
VisionSet
Simple one but can appear a bit odd.
short s = 5;
// fine the 5 is of type int but
// as it is literal is automatically narrowed to a short
myMethod(short s) {}
myMethod(5);
// not okay myMethod accepts a short
// and will not automatically narrow
// anything, even if it is literal.
& just to add:
myMethod((byte)5);
// fine, byte is narrower than short,
// this works on literals and variables
short s = 5;
// fine the 5 is of type int but
// as it is literal is automatically narrowed to a short
myMethod(short s) {}
myMethod(5);
// not okay myMethod accepts a short
// and will not automatically narrow
// anything, even if it is literal.
& just to add:
myMethod((byte)5);
// fine, byte is narrower than short,
// this works on literals and variables