bug icon indicating copy to clipboard operation
bug copied to clipboard

spurious unchecked warning due to non-local return

Open lrytz opened this issue 9 months ago • 0 comments

trait H[T]

class T {
  def m(): H[_] = {
    for (f <- Nil)
      return null.asInstanceOf[H[_]]
    null
  }
}

Warns

/Users/luc/code/scala/scala13/sandbox/T.scala:3: warning: non-variable type argument H[_$1] @unchecked forSome { type _$1 } in type pattern scala.runtime.NonLocalReturnControl[H[_$1] @unchecked forSome { type _$1 }] is unchecked since it is eliminated by erasure
class T {
        ^

The position of the warning at the enclosing class makes it hard to silence.

Similar to https://github.com/scala/bug/issues/5927, but that one is fixed.

lrytz avatar Mar 10 '25 12:03 lrytz