From 4cca17da5c5236c23e32c0a3298e4a097e335a0c Mon Sep 17 00:00:00 2001 From: Miguel Garcia Date: Sat, 7 Jul 2012 21:08:24 +0200 Subject: raise compile time error about impending VerifyError due to unsorted lookupswitch (SI-6011) --- src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/compiler') diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index 49a3a13247..32c100b026 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -1942,6 +1942,15 @@ abstract class GenASM extends SubComponent with BytecodeWriters { i += 1 } + // check for duplicate keys to avoid "VerifyError: unsorted lookupswitch" (SI-6011) + i = 1 + while (i < keys.length) { + if(keys(i-1) == keys(i)) { + abort("duplicate keys in SWITCH, can't pick arbitrarily one of them to evict, see SI-6011.") + } + i += 1 + } + val keyMin = keys(0) val keyMax = keys(keys.length - 1) -- cgit v1.2.3