scala/scala — pull request #1874 by paulp (2013-01-09 20:27:55+00:00)
Title: Made "mode" into a value class.

This is an obvious place to apply value class goodness and
collect some safety/sanity in typing modes. It does show off
a challenge in introducing value classes without disruption:
there's no way to deprecate the old signature of 'typed',
'adapt', etc. because they erase the same.

class Bippy(val x: Int) extends AnyVal
class A {
@deprecated("Use a bippy") def f(x: Int): Int = 5
def f(x: Bippy): Int = x.x
}

./a.scala:5: error: double definition:
method f:(x: Bippy)Int and
method f:(x: Int)Int at line 4
have same type after erasure: (x: Int)Int

An Int => Mode implicit handles most uses, but nothing can
be done to avoid breaking anything which e.g. extends Typer
and overrides typed.