posted 14 years ago
If you think about it, it is logical. The == operator allows comparison between byte and int because you might compare two variables i.e. something like this
So the compiler cannot tell whether i's value will be in the range of byte or not. But in the case of a switch statement, you cannot use variables as case values, so at the compile time you already know whether the case value is assignable to the switch expression or not. What is the whole point of allowing a case which can never be true?? In the example you showed, the case 128 can never be true, so what is the point of allowing it?? By flagging this as an error, the compiler helps you avoid such circumstances as its definitely a logical error...