Fixes Issue 4540 - Better diagnostic for wrong switch type.
Merge pull request #1417 from AndrejMitrovic/Fix4540

Issue 4540 - Better diagnostic for wrong switch type.