diff options
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/Meter.scala | 6 | ||||
-rw-r--r-- | test/files/run/MeterCaseClass.scala | 6 | ||||
-rw-r--r-- | test/files/run/t6260.check | 1 | ||||
-rw-r--r-- | test/files/run/t6260.scala | 12 | ||||
-rw-r--r-- | test/files/run/t6337a.scala | 16 | ||||
-rw-r--r-- | test/files/run/valueclasses-pavlov.check | 2 | ||||
-rw-r--r-- | test/files/run/valueclasses-pavlov.scala | 26 |
7 files changed, 65 insertions, 4 deletions
diff --git a/test/files/run/Meter.scala b/test/files/run/Meter.scala index d94f338ca9..a0c04cc2a7 100644 --- a/test/files/run/Meter.scala +++ b/test/files/run/Meter.scala @@ -2,7 +2,7 @@ package a { class Meter(val 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) @@ -12,6 +12,8 @@ package a { object Meter extends (Double => Meter) { + private[a] trait MeterArg + def apply(x: Double): Meter = new Meter(x) implicit val boxings = new BoxingConversions[Meter, Double] { @@ -80,7 +82,7 @@ object Test extends App { println(m) foo(arr) } - // + // // { println("testing wrapped arrays") // import collection.mutable.FlatArray // val arr = FlatArray(x, y + x) 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) diff --git a/test/files/run/t6260.check b/test/files/run/t6260.check new file mode 100644 index 0000000000..54f98a10f0 --- /dev/null +++ b/test/files/run/t6260.check @@ -0,0 +1 @@ +Box(abcabc) diff --git a/test/files/run/t6260.scala b/test/files/run/t6260.scala new file mode 100644 index 0000000000..cfe9e1e640 --- /dev/null +++ b/test/files/run/t6260.scala @@ -0,0 +1,12 @@ +class Box[X <: CharSequence](val x: X) extends AnyVal { + def map[Y <: CharSequence](f: X => Y): Box[Y] = + ((bx: Box[X]) => new Box(f(bx.x)))(this) + override def toString = s"Box($x)" +} + +object Test { + def main(args: Array[String]) { + val g = (x: String) => x + x + println(new Box("abc") map g) + } +} diff --git a/test/files/run/t6337a.scala b/test/files/run/t6337a.scala new file mode 100644 index 0000000000..f5490f5cf0 --- /dev/null +++ b/test/files/run/t6337a.scala @@ -0,0 +1,16 @@ +object Test { + def main(args: Array[String]) { + val x = X(XX(3)) + assert(x.q.x.x + 9 == 13) + } +} +trait Q extends Any { + def x: Int + def inc: XX +} +case class X(val x: Q) extends AnyVal { + def q = X(x.inc) +} +case class XX(val x: Int) extends AnyVal with Q { + def inc = XX(x + 1) +} diff --git a/test/files/run/valueclasses-pavlov.check b/test/files/run/valueclasses-pavlov.check new file mode 100644 index 0000000000..b112e5507e --- /dev/null +++ b/test/files/run/valueclasses-pavlov.check @@ -0,0 +1,2 @@ +box1: ok +box2: ok diff --git a/test/files/run/valueclasses-pavlov.scala b/test/files/run/valueclasses-pavlov.scala new file mode 100644 index 0000000000..e73897f653 --- /dev/null +++ b/test/files/run/valueclasses-pavlov.scala @@ -0,0 +1,26 @@ +trait Foo extends Any { + def box1(x: Box1): String + def box2(x: Box2): String +} + +class Box1(val value: String) extends AnyVal + +class Box2(val value: String) extends AnyVal with Foo { + def box1(x: Box1) = "box1: ok" + def box2(x: Box2) = "box2: ok" +} + +class C(x: String) { + def this() = this("") +} + +object Test { + + def main(args: Array[String]) { + val b1 = new Box1("") + val b2 = new Box2("") + val f: Foo = b2 + println(f.box1(b1)) + println(f.box2(b2)) + } +} |