scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

Compiler crash in erasure #13060

Closed lrytz closed 2 weeks ago

lrytz commented 2 weeks ago
class Bug1955 {
  var result: Int = 0
  def doSomething[A](a: Int, b: Int, r: A): A = {
    result = a + b
    r
  }
  def bug(x: Int, e: Boolean): Unit = {
    x match {
      case 1 => doSomething(123, 456, ())
      case 2 if e =>
    }

    if (false) ()
  }
}
Exception in thread "main" java.util.NoSuchElementException: key not found: class Nothing
    at scala.collection.immutable.BitmapIndexedMapNode.apply(HashMap.scala:674)
    at scala.collection.immutable.HashMap.apply(HashMap.scala:132)
    at scala.tools.nsc.transform.TypeAdaptingTransformer$TypeAdapter.box(TypeAdaptingTransformer.scala:74)
    at scala.tools.nsc.transform.TypeAdaptingTransformer$TypeAdapter.$anonfun$box$1(TypeAdaptingTransformer.scala:52)
    at scala.reflect.internal.Trees.deriveLabelDef(Trees.scala:2063)

https://github.com/scala/scala/commit/8b0637fa3c36c7310faadbd2906abc44acbdf9a2#diff-aa9646cbb31a4a381ea13b8a6a4ab58132646fd1fa7c2ff8195176ab872556dfL61