2

IntelliJ grays out this code. I think because it sees the throw and thinks the code is unreachable. However, it is reachable, because the throw is inside a lazy val:

lazy val handleMissing = {
  throw new IllegalStateException(s"Unbound type var $name")
}
map.getOrElse(name, handleMissing)

Same as code sample above

Scastie

jwvh
  • 50,871
  • 7
  • 38
  • 64
Max Heiber
  • 14,346
  • 12
  • 59
  • 97

1 Answers1

0

It's a bug: youtrack.jetbrains.com/issue/SCL-16859 Thanks @IlyaKlyuchnikov

A workaround is to pull the code out into a separate function.

Max Heiber
  • 14,346
  • 12
  • 59
  • 97