Closed
Description
Compiler version
3.3.1
Minimized code
def handle[E <: Exception](f: => Unit): Option[E] =
try
f
None
catch case e: E => Some(e)
val r: RuntimeException = handle[RuntimeException](throw new Exception()).get
Output
java.lang.ClassCastException: class java.lang.Exception cannot be cast to class java.lang.RuntimeException (java.lang.Exception and java.lang.RuntimeException are in module java.base of loader 'bootstrap')
Expectation
Fail compilation because type of E is not known in compile time, allow compilation for inline method (or maybe also by ClassTag in scope?).