Closed
Description
Compiler version
3.4.2-RC1
Minimized example
trait V:
type X = this.type match
case W[x] => x
trait W[+Y] extends V
extension (self: Any) def as[T]: T =
def asX(w: W[Any]): w.X /* <- reduces to Any */ = self
asX(new W[T] {}) /* <- reduces to T */
0.as[Boolean] // java.lang.ClassCastException
The issue is that w.X
reduces to Any
because the scrutinee w
is widened to W[Any]
before attempting the reduction of the match type.