From e171d6d969fe7ce0dd2fd7a7679d6edb08c7579c Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 19 Sep 2012 16:19:56 +0200 Subject: Value classes: eliminated half-boxing We now apply erasure of value classes everywhere. previously, erasure was disabled in the value class itself. This led to irregegularities and bugs. See test run/valueclasses-pavlov.scala for something that led to a ClassCastException before. --- test/files/run/MeterCaseClass.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'test/files/run/MeterCaseClass.scala') diff --git a/test/files/run/MeterCaseClass.scala b/test/files/run/MeterCaseClass.scala index e5979cf761..18f8e23f89 100644 --- a/test/files/run/MeterCaseClass.scala +++ b/test/files/run/MeterCaseClass.scala @@ -2,7 +2,7 @@ package a { case class Meter(underlying: Double) extends AnyVal with _root_.b.Printable { def + (other: Meter): Meter = new Meter(this.underlying + other.underlying) - def / (other: Meter): Double = this.underlying / other.underlying + def / (other: Meter)(implicit dummy: Meter.MeterArg = null): Double = this.underlying / other.underlying def / (factor: Double): Meter = new Meter(this.underlying / factor) def < (other: Meter): Boolean = this.underlying < other.underlying def toFoot: Foot = new Foot(this.underlying * 0.3048) @@ -11,6 +11,8 @@ package a { object Meter extends (Double => Meter) { + private[a] trait MeterArg + implicit val boxings = new BoxingConversions[Meter, Double] { def box(x: Double) = new Meter(x) def unbox(m: Meter) = m.underlying @@ -77,7 +79,7 @@ object Test extends App { println(m) foo(arr) } - // + // // { println("testing wrapped arrays") // import collection.mutable.FlatArray // val arr = FlatArray(x, y + x) -- cgit v1.2.3