Why cannot this case of implicit conversions be optimized?

Why cannot Scala optimize the following:

a.

implicit def whatever[A](a: A) = new { ... }

to:

b.

class some$generated$name(a: A) {
  ...
}
implicit def whatever[A](a: A) = new some$generated$name(a)

?

Why does it have to use structural typing in this case? I would like Scala compiler to perform this optimization as writing in style b is just too ugly (because, 1. locality of logic is lost, 2. you have to unnecessarily invent names for these additional explicit classes), and a is far less performant than b.

6
задан Jack 6 October 2010 в 02:42
поделиться