diff options
author | Paul Phillips <paulp@improving.org> | 2012-03-14 13:06:06 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-03-14 13:06:06 -0700 |
commit | 1c061e5931ccc39090d955e3bc18dd0a1e48df84 (patch) | |
tree | 4e351e3c3f3efa5a8e63c3d79bcb665d21d25630 /test | |
parent | a127aae2a5fbae146ea81e470541209436222970 (diff) | |
parent | 54e284d669418ebc6445bd0ec66804b9067f6dd3 (diff) | |
download | scala-1c061e5931ccc39090d955e3bc18dd0a1e48df84.tar.gz scala-1c061e5931ccc39090d955e3bc18dd0a1e48df84.tar.bz2 scala-1c061e5931ccc39090d955e3bc18dd0a1e48df84.zip |
Merge remote-tracking branch 'odersky/topic/inline' into merge-inline
Conflicts:
lib/scala-compiler.jar.desired.sha1
lib/scala-library-src.jar.desired.sha1
lib/scala-library.jar.desired.sha1
src/compiler/scala/reflect/internal/Definitions.scala
src/compiler/scala/reflect/internal/Symbols.scala
src/compiler/scala/tools/nsc/Global.scala
src/compiler/scala/tools/nsc/transform/Constructors.scala
src/compiler/scala/tools/nsc/transform/Erasure.scala
src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
src/compiler/scala/tools/nsc/typechecker/Contexts.scala
src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
src/library/scala/Function0.scala
src/library/scala/Function1.scala
src/library/scala/Function10.scala
src/library/scala/Function11.scala
src/library/scala/Function12.scala
src/library/scala/Function13.scala
src/library/scala/Function14.scala
src/library/scala/Function15.scala
src/library/scala/Function16.scala
src/library/scala/Function17.scala
src/library/scala/Function18.scala
src/library/scala/Function19.scala
src/library/scala/Function2.scala
src/library/scala/Function20.scala
src/library/scala/Function21.scala
src/library/scala/Function22.scala
src/library/scala/Function3.scala
src/library/scala/Function4.scala
src/library/scala/Function5.scala
src/library/scala/Function6.scala
src/library/scala/Function7.scala
src/library/scala/Function8.scala
src/library/scala/Function9.scala
test/files/codelib/code.jar.desired.sha1
test/files/neg/anyval-children-2.check
test/files/run/programmatic-main.check
Diffstat (limited to 'test')
47 files changed, 496 insertions, 95 deletions
diff --git a/test/files/jvm/manifests.check b/test/files/jvm/manifests.check index 453db81a3b..54f504b929 100644 --- a/test/files/jvm/manifests.check +++ b/test/files/jvm/manifests.check @@ -29,7 +29,7 @@ x=Foo, m=Foo[scala.collection.immutable.List[Int]] x=Foo, m=Foo[Foo[Int]] x=Foo, m=Foo[scala.collection.immutable.List[Foo[Int]]] -x=Test1$$anon$1, m=Object with Bar[java.lang.String] with Object +x=Test1$$anon$1, m=Object with Bar[java.lang.String] ()=() true=true diff --git a/test/files/neg/anytrait.check b/test/files/neg/anytrait.check new file mode 100644 index 0000000000..9dd970b58c --- /dev/null +++ b/test/files/neg/anytrait.check @@ -0,0 +1,7 @@ +anytrait.scala:3: error: this statement is not allowed in universal trait extending from class Any: private[this] var x: Int = 1 + var x = 1 + ^ +anytrait.scala:5: error: this statement is not allowed in universal trait extending from class Any: T.this.x_=(T.this.x.+(1)) + { x += 1 } + ^ +two errors found diff --git a/test/files/neg/anytrait.scala b/test/files/neg/anytrait.scala new file mode 100644 index 0000000000..1501486105 --- /dev/null +++ b/test/files/neg/anytrait.scala @@ -0,0 +1,10 @@ +trait T extends Any { + + var x = 1 + + { x += 1 } + + type T = Int + + val y: T +} diff --git a/test/files/neg/anyval-anyref-parent.check b/test/files/neg/anyval-anyref-parent.check index b40a0f2710..fe20e5de81 100644 --- a/test/files/neg/anyval-anyref-parent.check +++ b/test/files/neg/anyval-anyref-parent.check @@ -1,4 +1,23 @@ +anyval-anyref-parent.scala:2: error: only classes (not traits) are allowed to extend AnyVal +trait Foo2 extends AnyVal // fail + ^ anyval-anyref-parent.scala:5: error: Any does not have a constructor class Bar1 extends Any // fail ^ -one error found +anyval-anyref-parent.scala:6: error: value class needs to have exactly one public val parameter +class Bar2(x: Int) extends AnyVal // fail + ^ +anyval-anyref-parent.scala:10: error: illegal inheritance; superclass Any + is not a subclass of the superclass Object + of the mixin trait Immutable +trait Foo4 extends Any with Immutable // fail + ^ +anyval-anyref-parent.scala:11: error: illegal inheritance; superclass AnyVal + is not a subclass of the superclass Object + of the mixin trait Immutable +trait Foo5 extends AnyVal with Immutable // fail + ^ +anyval-anyref-parent.scala:11: error: only classes (not traits) are allowed to extend AnyVal +trait Foo5 extends AnyVal with Immutable // fail + ^ +6 errors found diff --git a/test/files/neg/anyval-anyref-parent.scala b/test/files/neg/anyval-anyref-parent.scala index b7bb122ea8..f927992e59 100644 --- a/test/files/neg/anyval-anyref-parent.scala +++ b/test/files/neg/anyval-anyref-parent.scala @@ -1,7 +1,12 @@ trait Foo1 extends Any -trait Foo2 extends AnyVal +trait Foo2 extends AnyVal // fail trait Foo3 extends AnyRef class Bar1 extends Any // fail -@inline class Bar2 extends AnyVal -class Bar3 extends AnyRef +class Bar2(x: Int) extends AnyVal // fail +class Bar3(val x: Int) extends AnyVal // fail +class Bar4 extends AnyRef + +trait Foo4 extends Any with Immutable // fail +trait Foo5 extends AnyVal with Immutable // fail +trait Foo6 extends AnyRef with Immutable diff --git a/test/files/neg/anyval-children-2.check b/test/files/neg/anyval-children-2.check deleted file mode 100644 index a88682ea93..0000000000 --- a/test/files/neg/anyval-children-2.check +++ /dev/null @@ -1,4 +0,0 @@ -anyval-children-2.scala:1: error: Only classes (not traits) are allowed to extend AnyVal -@inline trait NotOkDingus1 extends AnyVal // fail - ^ -one error found diff --git a/test/files/neg/anyval-children-2.scala b/test/files/neg/anyval-children-2.scala deleted file mode 100644 index 4034eb22dd..0000000000 --- a/test/files/neg/anyval-children-2.scala +++ /dev/null @@ -1 +0,0 @@ -@inline trait NotOkDingus1 extends AnyVal // fail diff --git a/test/files/neg/anyval-children.check b/test/files/neg/anyval-children.check deleted file mode 100644 index 769f990210..0000000000 --- a/test/files/neg/anyval-children.check +++ /dev/null @@ -1,23 +0,0 @@ -anyval-children.scala:3: error: class AnyVal needs to be a trait to be mixed in -@inline class NotOkDingus2 extends Immutable with AnyVal // fail - ^ -anyval-children.scala:7: error: Bippy does not have a constructor -class NotOkBippy1 extends Bippy // fail - ^ -anyval-children.scala:9: error: illegal inheritance; superclass Bippy - is not a subclass of the superclass Object - of the mixin trait Immutable -class NotOkBippy2 extends Bippy with Immutable //fail - ^ -anyval-children.scala:9: error: Bippy does not have a constructor -class NotOkBippy2 extends Bippy with Immutable //fail - ^ -anyval-children.scala:11: error: illegal inheritance; superclass Bippy - is not a subclass of the superclass Object - of the mixin trait Immutable -@inline class NotOkBippy3 extends Bippy with Immutable //fail - ^ -anyval-children.scala:11: error: Bippy does not have a constructor -@inline class NotOkBippy3 extends Bippy with Immutable //fail - ^ -6 errors found diff --git a/test/files/neg/anyval-children.scala b/test/files/neg/anyval-children.scala deleted file mode 100644 index 5a6109f786..0000000000 --- a/test/files/neg/anyval-children.scala +++ /dev/null @@ -1,14 +0,0 @@ -class Bippy extends AnyVal // fail - -@inline class NotOkDingus2 extends Immutable with AnyVal // fail - -@inline object NotOkDingus3 extends AnyVal // fail - -class NotOkBippy1 extends Bippy // fail - -class NotOkBippy2 extends Bippy with Immutable //fail - -@inline class NotOkBippy3 extends Bippy with Immutable //fail - - -@inline class OkBippy extends AnyVal // ok diff --git a/test/files/neg/t3222.check b/test/files/neg/t3222.check index b1e1e50448..e724024f45 100644 --- a/test/files/neg/t3222.check +++ b/test/files/neg/t3222.check @@ -1,7 +1,7 @@ -t3222.scala:1: error: not found: type B -@throws(classOf[B]) - ^ t3222.scala:4: error: not found: type D def foo(@throws(classOf[D]) x: Int) {} ^ +t3222.scala:1: error: not found: type B +@throws(classOf[B]) + ^ two errors found diff --git a/test/files/neg/t900.check b/test/files/neg/t900.check index cede26258b..047094ad6e 100644 --- a/test/files/neg/t900.check +++ b/test/files/neg/t900.check @@ -2,8 +2,8 @@ t900.scala:4: error: type mismatch; found : Foo.this.x.type (with underlying type Foo.this.bar) required: AnyRef Note that implicit conversions are not applicable because they are ambiguous: - both method any2Ensuring in object Predef of type [A](x: A)Ensuring[A] - and method any2ArrowAssoc in object Predef of type [A](x: A)ArrowAssoc[A] + both method any2stringadd in object Predef of type (x: Any)scala.runtime.StringAdd + and method any2stringfmt in object Predef of type (x: Any)scala.runtime.StringFormat are possible conversion functions from Foo.this.x.type to AnyRef def break(): x.type ^ diff --git a/test/files/neg/valueclasses-doubledefs.check b/test/files/neg/valueclasses-doubledefs.check new file mode 100644 index 0000000000..556d7a0900 --- /dev/null +++ b/test/files/neg/valueclasses-doubledefs.check @@ -0,0 +1,7 @@ +valueclasses-doubledefs.scala:5: error: double definition: +method apply:(x: Meter)String and +method apply:(x: Double)String at line 4 +have same type after erasure: (x: Double)String + def apply(x: Meter) = x.toString + ^ +one error found diff --git a/test/files/neg/valueclasses-doubledefs.scala b/test/files/neg/valueclasses-doubledefs.scala new file mode 100644 index 0000000000..87bcf8fee3 --- /dev/null +++ b/test/files/neg/valueclasses-doubledefs.scala @@ -0,0 +1,6 @@ +class Meter(val x: Double) extends AnyVal + +class Foo { + def apply(x: Double) = x.toString + def apply(x: Meter) = x.toString +} diff --git a/test/files/neg/valueclasses.check b/test/files/neg/valueclasses.check new file mode 100644 index 0000000000..756a0474fa --- /dev/null +++ b/test/files/neg/valueclasses.check @@ -0,0 +1,46 @@ +valueclasses.scala:3: error: only classes (not traits) are allowed to extend AnyVal +trait T extends AnyVal // fail + ^ +valueclasses.scala:6: error: value class may not be a member of another class + class Bar(x: Int) extends AnyVal // fail + ^ +valueclasses.scala:8: error: value class may not be a local class + class Baz(x: Int) extends AnyVal // fail + ^ +valueclasses.scala:12: error: value class needs to have exactly one public val parameter +class V1 extends AnyVal // fail + ^ +valueclasses.scala:14: error: value class needs to have a publicly accessible val parameter +class V2(private[test] val x: Int) extends AnyVal // fail + ^ +valueclasses.scala:15: error: value class needs to have a publicly accessible val parameter +class V3(protected[test] val x: Int) extends AnyVal // fail + ^ +valueclasses.scala:16: error: value class needs to have a publicly accessible val parameter +class V4(protected val x: Int) extends AnyVal // fail + ^ +valueclasses.scala:17: error: value class needs to have a publicly accessible val parameter +class V5(private val x: Int) extends AnyVal // fail + ^ +valueclasses.scala:19: error: value class needs to have exactly one public val parameter +class V6(val x: Int, val y: String) extends AnyVal // fail + ^ +valueclasses.scala:20: error: illegal parameter for value class +class V7(val x: Int, private[this] val y: String) extends AnyVal // fail + ^ +valueclasses.scala:21: error: value class needs to have exactly one public val parameter +class V8(var x: Int) extends AnyVal // fail + ^ +valueclasses.scala:24: error: this statement is not allowed in value class: private[this] val y: Int = V9.this.x + val y = x // fail + ^ +valueclasses.scala:29: error: type parameter of value class may not be specialized +class V12[@specialized T, U](val x: (T, U)) extends AnyVal // fail + ^ +valueclasses.scala:31: error: value class needs to have exactly one public val parameter +class V13(x: Int) extends AnyVal // fail + ^ +valueclasses.scala:45: error: value class must have public primary constructor +final class TOD private (val secondsOfDay: Int) extends AnyVal { // should fail with private constructor + ^ +15 errors found diff --git a/test/files/neg/valueclasses.scala b/test/files/neg/valueclasses.scala new file mode 100644 index 0000000000..e405d95489 --- /dev/null +++ b/test/files/neg/valueclasses.scala @@ -0,0 +1,54 @@ +package test + +trait T extends AnyVal // fail + +class Foo { + class Bar(x: Int) extends AnyVal // fail + def foo() { + class Baz(x: Int) extends AnyVal // fail + } +} + +class V1 extends AnyVal // fail + +class V2(private[test] val x: Int) extends AnyVal // fail +class V3(protected[test] val x: Int) extends AnyVal // fail +class V4(protected val x: Int) extends AnyVal // fail +class V5(private val x: Int) extends AnyVal // fail + +class V6(val x: Int, val y: String) extends AnyVal // fail +class V7(val x: Int, private[this] val y: String) extends AnyVal // fail +class V8(var x: Int) extends AnyVal // fail + +class V9(val x: Int) extends AnyVal { + val y = x // fail +} + +class V10[T](val x: T) extends AnyVal // ok +class V11[T](val x: List[T]) extends AnyVal // ok +class V12[@specialized T, U](val x: (T, U)) extends AnyVal // fail + +class V13(x: Int) extends AnyVal // fail + + +package time { + +object TOD { + final val SecondsPerDay = 86400 + + def apply(seconds: Int) = { + val n = seconds % SecondsPerDay + new TOD(if (n >= 0) n else n + SecondsPerDay) + } +} + +final class TOD private (val secondsOfDay: Int) extends AnyVal { // should fail with private constructor + def hours = secondsOfDay / 3600 + def minutes = (secondsOfDay / 60) % 60 + def seconds = secondsOfDay % 60 + + override def toString = "%02d:%02d:%02d".format(hours, minutes, seconds) +} +} + + diff --git a/test/files/pos/anyval-children.scala b/test/files/pos/anyval-children.scala deleted file mode 100644 index 4ef10a094f..0000000000 --- a/test/files/pos/anyval-children.scala +++ /dev/null @@ -1 +0,0 @@ -@inline class Bippy extends AnyVal
\ No newline at end of file diff --git a/test/files/pos/t715/meredith_1.scala b/test/files/pos/t715/meredith_1.scala index 3ed2e57d7a..8261b9881a 100644 --- a/test/files/pos/t715/meredith_1.scala +++ b/test/files/pos/t715/meredith_1.scala @@ -3,7 +3,7 @@ package com.sap.dspace.model.othello; import scala.xml._ trait XMLRenderer { - type T <: {def getClass() : java.lang.Class[_]} + type T <: Any {def getClass() : java.lang.Class[_]} val valueTypes = List( classOf[java.lang.Boolean], diff --git a/test/files/run/Meter.check b/test/files/run/Meter.check new file mode 100644 index 0000000000..7562f9a1bf --- /dev/null +++ b/test/files/run/Meter.check @@ -0,0 +1,21 @@ +2.0 +4.0m +false +x.isInstanceOf[Meter]: true +x.hashCode: 1072693248 +x == 1: false +x == y: true +a == b: true +testing native arrays +Array(1.0m, 2.0m) +1.0m +>>>1.0m<<< 1.0m +>>>2.0m<<< 2.0m +testing wrapped arrays +FlatArray(1.0m, 2.0m) +1.0m +>>>1.0m<<< 1.0m +>>>2.0m<<< 2.0m +FlatArray(2.0m, 3.0m) +ArrayBuffer(1.0, 2.0) +FlatArray(0.3048ft, 0.6096ft) diff --git a/test/files/run/Meter.scala b/test/files/run/Meter.scala new file mode 100644 index 0000000000..42a3aac5f8 --- /dev/null +++ b/test/files/run/Meter.scala @@ -0,0 +1,102 @@ +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 / (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) + override def print = { Console.print(">>>"); super.print; proprint } + override def toString: String = underlying.toString+"m" + } + + object Meter extends (Double => Meter) { + + def apply(x: Double): Meter = new Meter(x) + + implicit val boxings = new BoxingConversions[Meter, Double] { + def box(x: Double) = new Meter(x) + def unbox(m: Meter) = m.underlying + } + } + + class Foot(val unbox: Double) extends AnyVal { + def + (other: Foot): Foot = + new Foot(this.unbox + other.unbox) + override def toString = unbox.toString+"ft" + } + object Foot { + implicit val boxings = new BoxingConversions[Foot, Double] { + def box(x: Double) = new Foot(x) + def unbox(m: Foot) = m.unbox + } + } + +} +package b { + trait Printable extends Any { + def print: Unit = Console.print(this) + protected def proprint = Console.print("<<<") + } +} +import a._ +import _root_.b._ +object Test extends App { + + { + val x: Meter = new Meter(1) + val a: Object = x.asInstanceOf[Object] + val y: Meter = a.asInstanceOf[Meter] + + val u: Double = 1 + val b: Object = u.asInstanceOf[Object] + val v: Double = b.asInstanceOf[Double] + } + + val x = new Meter(1) + val y = x + println((x + x) / x) + println((x + x) / 0.5) + println((x < x).toString) + println("x.isInstanceOf[Meter]: "+x.isInstanceOf[Meter]) + + + println("x.hashCode: "+x.hashCode) + println("x == 1: "+(x == 1)) + println("x == y: "+(x == y)) + assert(x.hashCode == (1.0).hashCode) + + val a: Any = x + val b: Any = y + println("a == b: "+(a == b)) + + { println("testing native arrays") + val arr = Array(x, y + x) + println(arr.deep) + def foo[T <: Printable](x: Array[T]) { + for (i <- 0 until x.length) { x(i).print; println(" "+x(i)) } + } + val m = arr(0) + println(m) + foo(arr) + } + + { println("testing wrapped arrays") + import collection.mutable.FlatArray + val arr = FlatArray(x, y + x) + println(arr) + def foo(x: FlatArray[Meter]) { + for (i <- 0 until x.length) { x(i).print; println(" "+x(i)) } + } + val m = arr(0) + println(m) + foo(arr) + val ys: Seq[Meter] = arr map (_ + new Meter(1)) + println(ys) + val zs = arr map (_ / Meter(1)) + println(zs) + val fs = arr map (_.toFoot) + println(fs) + } + +} diff --git a/test/files/run/MeterCaseClass.check b/test/files/run/MeterCaseClass.check new file mode 100644 index 0000000000..08370d2097 --- /dev/null +++ b/test/files/run/MeterCaseClass.check @@ -0,0 +1,21 @@ +2.0 +Meter(4.0) +false +x.isInstanceOf[Meter]: true +x.hashCode: 1072693248 +x == 1: false +x == y: true +a == b: true +testing native arrays +Array(Meter(1.0), Meter(2.0)) +Meter(1.0) +>>>Meter(1.0)<<< Meter(1.0) +>>>Meter(2.0)<<< Meter(2.0) +testing wrapped arrays +FlatArray(Meter(1.0), Meter(2.0)) +Meter(1.0) +>>>Meter(1.0)<<< Meter(1.0) +>>>Meter(2.0)<<< Meter(2.0) +FlatArray(Meter(2.0), Meter(3.0)) +ArrayBuffer(1.0, 2.0) +FlatArray(0.3048ft, 0.6096ft) diff --git a/test/files/run/MeterCaseClass.scala b/test/files/run/MeterCaseClass.scala new file mode 100644 index 0000000000..4f082b5252 --- /dev/null +++ b/test/files/run/MeterCaseClass.scala @@ -0,0 +1,99 @@ +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 / (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) + override def print = { Console.print(">>>"); super.print; proprint } + } + + object Meter extends (Double => Meter) { + + implicit val boxings = new BoxingConversions[Meter, Double] { + def box(x: Double) = new Meter(x) + def unbox(m: Meter) = m.underlying + } + } + + class Foot(val unbox: Double) extends AnyVal { + def + (other: Foot): Foot = + new Foot(this.unbox + other.unbox) + override def toString = unbox.toString+"ft" + } + object Foot { + implicit val boxings = new BoxingConversions[Foot, Double] { + def box(x: Double) = new Foot(x) + def unbox(m: Foot) = m.unbox + } + } + +} +package b { + trait Printable extends Any { + def print: Unit = Console.print(this) + protected def proprint = Console.print("<<<") + } +} +import a._ +import _root_.b._ +object Test extends App { + + { + val x: Meter = new Meter(1) + val a: Object = x.asInstanceOf[Object] + val y: Meter = a.asInstanceOf[Meter] + + val u: Double = 1 + val b: Object = u.asInstanceOf[Object] + val v: Double = b.asInstanceOf[Double] + } + + val x = new Meter(1) + val y = x + println((x + x) / x) + println((x + x) / 0.5) + println((x < x).toString) + println("x.isInstanceOf[Meter]: "+x.isInstanceOf[Meter]) + + + println("x.hashCode: "+x.hashCode) + println("x == 1: "+(x == 1)) + println("x == y: "+(x == y)) + assert(x.hashCode == (1.0).hashCode) + + val a: Any = x + val b: Any = y + println("a == b: "+(a == b)) + + { println("testing native arrays") + val arr = Array(x, y + x) + println(arr.deep) + def foo[T <: Printable](x: Array[T]) { + for (i <- 0 until x.length) { x(i).print; println(" "+x(i)) } + } + val m = arr(0) + println(m) + foo(arr) + } + + { println("testing wrapped arrays") + import collection.mutable.FlatArray + val arr = FlatArray(x, y + x) + println(arr) + def foo(x: FlatArray[Meter]) { + for (i <- 0 until x.length) { x(i).print; println(" "+x(i)) } + } + val m = arr(0) + println(m) + foo(arr) + val ys: Seq[Meter] = arr map (_ + new Meter(1)) + println(ys) + val zs = arr map (_ / Meter(1)) + println(zs) + val fs = arr map (_.toFoot) + println(fs) + } + +} diff --git a/test/files/run/genericValueClass.check b/test/files/run/genericValueClass.check new file mode 100644 index 0000000000..ec3a41a6a9 --- /dev/null +++ b/test/files/run/genericValueClass.check @@ -0,0 +1,2 @@ +(1,abc) +(2,def) diff --git a/test/files/run/genericValueClass.scala b/test/files/run/genericValueClass.scala new file mode 100644 index 0000000000..68162bb685 --- /dev/null +++ b/test/files/run/genericValueClass.scala @@ -0,0 +1,17 @@ +final class ArrowAssoc[A](val __leftOfArrow: A) extends AnyVal { + @inline def -> [B](y: B): Tuple2[A, B] = Tuple2(__leftOfArrow, y) + def →[B](y: B): Tuple2[A, B] = ->(y) +} + +object Test extends App { + { + @inline implicit def any2ArrowAssoc[A](x: A): ArrowAssoc[A] = new ArrowAssoc(x) + val x = 1 -> "abc" + println(x) + } + + { + val y = 2 -> "def" + println(y) + } +} diff --git a/test/files/run/primitive-sigs-2.check b/test/files/run/primitive-sigs-2.check index 0af1434cea..feb0619525 100644 --- a/test/files/run/primitive-sigs-2.check +++ b/test/files/run/primitive-sigs-2.check @@ -1,4 +1,4 @@ -T<java.lang.Object> class java.lang.Object +T<java.lang.Object> List(A, char, class java.lang.Object) a public <T> java.lang.Object Arr.arr4(java.lang.Object[],scala.reflect.Manifest<T>) diff --git a/test/files/run/programmatic-main.check b/test/files/run/programmatic-main.check index b5a54f5ea7..d16e2c5178 100644 --- a/test/files/run/programmatic-main.check +++ b/test/files/run/programmatic-main.check @@ -4,8 +4,8 @@ namer 2 resolve names, attach symbols to named trees packageobjects 3 load package objects typer 4 the meat and potatoes: type the trees - extmethods 5 add extension methods for inline classes - superaccessors 6 add super accessors in traits and nested classes + superaccessors 5 add super accessors in traits and nested classes + extmethods 6 add extension methods for inline classes pickler 7 serialize symbol tables refchecks 8 reference/override checking, translate nested objects uncurry 9 uncurry, translate function values to anonymous classes @@ -13,17 +13,18 @@ specialize 11 @specialized-driven class and method specialization explicitouter 12 this refs to outer pointers, translate patterns erasure 13 erase types, add interfaces for traits - lazyvals 14 allocate bitmaps, translate lazy vals into lazified defs - lambdalift 15 move nested functions to top level - constructors 16 move field definitions into constructors - flatten 17 eliminate inner classes - mixin 18 mixin composition - cleanup 19 platform-specific cleanups, generate reflective calls - icode 20 generate portable intermediate code - inliner 21 optimization: do inlining -inlineExceptionHandlers 22 optimization: inline exception handlers - closelim 23 optimization: eliminate uncalled closures - dce 24 optimization: eliminate dead code - jvm 25 generate JVM bytecode - terminal 26 The last phase in the compiler chain + posterasure 14 clean up erased inline classes + lazyvals 15 allocate bitmaps, translate lazy vals into lazified defs + lambdalift 16 move nested functions to top level + constructors 17 move field definitions into constructors + flatten 18 eliminate inner classes + mixin 19 mixin composition + cleanup 20 platform-specific cleanups, generate reflective calls + icode 21 generate portable intermediate code + inliner 22 optimization: do inlining +inlineExceptionHandlers 23 optimization: inline exception handlers + closelim 24 optimization: eliminate uncalled closures + dce 25 optimization: eliminate dead code + jvm 26 generate JVM bytecode + terminal 27 The last phase in the compiler chain diff --git a/test/files/run/t4110.check b/test/files/run/t4110.check index dea7e5957c..8b005989de 100644 --- a/test/files/run/t4110.check +++ b/test/files/run/t4110.check @@ -1,2 +1,2 @@ -Object with Test$A with Test$B with Object -Object with Test$A with Test$B with Object +Object with Test$A with Test$B +Object with Test$A with Test$B diff --git a/test/files/run/t4172.check b/test/files/run/t4172.check index b94da0c9d8..da467e27ea 100644 --- a/test/files/run/t4172.check +++ b/test/files/run/t4172.check @@ -4,7 +4,7 @@ Type :help for more information. scala> scala> val c = { class C { override def toString = "C" }; ((new C, new C { def f = 2 })) } -c: (C, C with Object{def f: Int}) forSome { type C <: Object } = (C,C) +c: (C, C{def f: Int}) forSome { type C <: Object } = (C,C) scala> diff --git a/test/files/run/valueclasses-constr.check b/test/files/run/valueclasses-constr.check new file mode 100644 index 0000000000..df37fbc723 --- /dev/null +++ b/test/files/run/valueclasses-constr.check @@ -0,0 +1,2 @@ +0 +00:16:40 diff --git a/test/files/run/valueclasses-constr.scala b/test/files/run/valueclasses-constr.scala new file mode 100644 index 0000000000..7a10299386 --- /dev/null +++ b/test/files/run/valueclasses-constr.scala @@ -0,0 +1,25 @@ +object TOD { + final val SecondsPerDay = 86400 + + def apply(seconds: Int) = { + val n = seconds % SecondsPerDay + new TOD(if (n >= 0) n else n + SecondsPerDay) + } +} + +final class TOD (val secondsOfDay: Int) extends AnyVal { + def hours = secondsOfDay / 3600 + def minutes = (secondsOfDay / 60) % 60 + def seconds = secondsOfDay % 60 + + override def toString = "%02d:%02d:%02d".format(hours, minutes, seconds) +} + +object Test extends App { + + val y: TOD = new TOD(1000) + val x: TOD = TOD(1000) + println(x.hours) + println(x) +} + diff --git a/test/files/scalap/abstractClass/result.test b/test/files/scalap/abstractClass/result.test index 98c5047cbc..9163346fc6 100644 --- a/test/files/scalap/abstractClass/result.test +++ b/test/files/scalap/abstractClass/result.test @@ -1,4 +1,4 @@ -abstract class AbstractClass extends java.lang.Object with scala.AnyRef { +abstract class AbstractClass extends java.lang.Object { def this() = { /* compiled code */ } def foo : scala.Predef.String } diff --git a/test/files/scalap/abstractMethod/result.test b/test/files/scalap/abstractMethod/result.test index 062a458c13..90f572f258 100644 --- a/test/files/scalap/abstractMethod/result.test +++ b/test/files/scalap/abstractMethod/result.test @@ -1,4 +1,4 @@ -trait AbstractMethod extends java.lang.Object with scala.AnyRef { +trait AbstractMethod extends java.lang.Object { def $init$() : scala.Unit = { /* compiled code */ } def arity : scala.Int def isCool : scala.Boolean = { /* compiled code */ } diff --git a/test/files/scalap/caseClass/result.test b/test/files/scalap/caseClass/result.test index 7c94b52cf7..7dfe3a0356 100644 --- a/test/files/scalap/caseClass/result.test +++ b/test/files/scalap/caseClass/result.test @@ -1,4 +1,4 @@ -case class CaseClass[A <: scala.Seq[scala.Int]](i : A, s : scala.Predef.String) extends java.lang.Object with scala.Product with scala.Serializable with scala.AnyRef { +case class CaseClass[A <: scala.Seq[scala.Int]](i : A, s : scala.Predef.String) extends scala.AnyRef with scala.Product with scala.Serializable { val i : A = { /* compiled code */ } val s : scala.Predef.String = { /* compiled code */ } def foo : scala.Int = { /* compiled code */ } diff --git a/test/files/scalap/caseObject/result.test b/test/files/scalap/caseObject/result.test index 9c66c6ebb1..867a4b2162 100644 --- a/test/files/scalap/caseObject/result.test +++ b/test/files/scalap/caseObject/result.test @@ -1,4 +1,4 @@ -case object CaseObject extends java.lang.Object with scala.Product with scala.Serializable { +case object CaseObject extends scala.AnyRef with scala.Product with scala.Serializable { def bar : scala.Int = { /* compiled code */ } override def productPrefix : java.lang.String = { /* compiled code */ } def productArity : scala.Int = { /* compiled code */ } diff --git a/test/files/scalap/cbnParam/result.test b/test/files/scalap/cbnParam/result.test index d00a13d2d7..fbe035d63c 100644 --- a/test/files/scalap/cbnParam/result.test +++ b/test/files/scalap/cbnParam/result.test @@ -1,3 +1,3 @@ -class CbnParam extends java.lang.Object with scala.AnyRef { +class CbnParam extends java.lang.Object { def this(s : => scala.Predef.String) = { /* compiled code */ } } diff --git a/test/files/scalap/classPrivate/result.test b/test/files/scalap/classPrivate/result.test index 1846b7f0ea..5f2e1cc00e 100644 --- a/test/files/scalap/classPrivate/result.test +++ b/test/files/scalap/classPrivate/result.test @@ -1,10 +1,10 @@ -class ClassPrivate extends java.lang.Object with scala.AnyRef { +class ClassPrivate extends java.lang.Object { def this() = { /* compiled code */ } def baz : scala.Int = { /* compiled code */ } - class Outer extends java.lang.Object with scala.AnyRef { + class Outer extends java.lang.Object { def this() = { /* compiled code */ } private[ClassPrivate] def qux : scala.Int = { /* compiled code */ } } protected def quux : scala.Int = { /* compiled code */ } private[ClassPrivate] def bar : scala.Int = { /* compiled code */ } -}
\ No newline at end of file +} diff --git a/test/files/scalap/classWithExistential/result.test b/test/files/scalap/classWithExistential/result.test index 078b93ad89..b8ce005da9 100644 --- a/test/files/scalap/classWithExistential/result.test +++ b/test/files/scalap/classWithExistential/result.test @@ -1,4 +1,4 @@ -class ClassWithExistential extends java.lang.Object with scala.AnyRef { +class ClassWithExistential extends java.lang.Object { def this() = { /* compiled code */ } def foo[A, B] : scala.Function1[A, B forSome {type A <: scala.Seq[scala.Int]; type B >: scala.Predef.String}] = { /* compiled code */ } -}
\ No newline at end of file +} diff --git a/test/files/scalap/classWithSelfAnnotation/result.test b/test/files/scalap/classWithSelfAnnotation/result.test index 37b2bae5e0..df7bd86643 100644 --- a/test/files/scalap/classWithSelfAnnotation/result.test +++ b/test/files/scalap/classWithSelfAnnotation/result.test @@ -1,4 +1,4 @@ -class ClassWithSelfAnnotation extends java.lang.Object with scala.AnyRef { +class ClassWithSelfAnnotation extends java.lang.Object { this : ClassWithSelfAnnotation with java.lang.CharSequence => def this() = { /* compiled code */ } def foo : scala.Int = { /* compiled code */ } diff --git a/test/files/scalap/covariantParam/result.test b/test/files/scalap/covariantParam/result.test index 9e4dbb802d..2f52f1f28e 100644 --- a/test/files/scalap/covariantParam/result.test +++ b/test/files/scalap/covariantParam/result.test @@ -1,4 +1,4 @@ -class CovariantParam[+A] extends java.lang.Object with scala.AnyRef { +class CovariantParam[+A] extends java.lang.Object { def this() = { /* compiled code */ } def foo[A](a : A) : scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/implicitParam/result.test b/test/files/scalap/implicitParam/result.test index 05be2f9ae1..0ea212dda6 100644 --- a/test/files/scalap/implicitParam/result.test +++ b/test/files/scalap/implicitParam/result.test @@ -1,4 +1,4 @@ -class ImplicitParam extends java.lang.Object with scala.AnyRef { +class ImplicitParam extends java.lang.Object { def this() = { /* compiled code */ } def foo(i : scala.Int)(implicit f : scala.Float, d : scala.Double) : scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/paramClauses/result.test b/test/files/scalap/paramClauses/result.test index ff7c879933..dc4397386c 100644 --- a/test/files/scalap/paramClauses/result.test +++ b/test/files/scalap/paramClauses/result.test @@ -1,4 +1,4 @@ -class ParamClauses extends java.lang.Object with scala.AnyRef { +class ParamClauses extends java.lang.Object { def this() = { /* compiled code */ } def foo(i : scala.Int)(s : scala.Predef.String)(t : scala.Double) : scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/paramNames/result.test b/test/files/scalap/paramNames/result.test index a18c6350e3..4d3c7d0c1e 100644 --- a/test/files/scalap/paramNames/result.test +++ b/test/files/scalap/paramNames/result.test @@ -1,4 +1,4 @@ -class ParamNames extends java.lang.Object with scala.AnyRef { +class ParamNames extends java.lang.Object { def this() = { /* compiled code */ } def foo(s : => scala.Seq[scala.Int], s2 : => scala.Seq[scala.Any]) : scala.Unit = { /* compiled code */ } } diff --git a/test/files/scalap/sequenceParam/result.test b/test/files/scalap/sequenceParam/result.test index ca004ab0bf..ed47c094fe 100644 --- a/test/files/scalap/sequenceParam/result.test +++ b/test/files/scalap/sequenceParam/result.test @@ -1,3 +1,3 @@ -class SequenceParam extends java.lang.Object with scala.AnyRef { +class SequenceParam extends java.lang.Object { def this(s : scala.Predef.String, i : scala.Int*) = { /* compiled code */ } } diff --git a/test/files/scalap/simpleClass/result.test b/test/files/scalap/simpleClass/result.test index f350720895..905046ce52 100644 --- a/test/files/scalap/simpleClass/result.test +++ b/test/files/scalap/simpleClass/result.test @@ -1,4 +1,4 @@ -class SimpleClass extends java.lang.Object with scala.AnyRef { +class SimpleClass extends java.lang.Object { def this() = { /* compiled code */ } def foo : scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/traitObject/result.test b/test/files/scalap/traitObject/result.test index e9a72316e9..d0521043c8 100644 --- a/test/files/scalap/traitObject/result.test +++ b/test/files/scalap/traitObject/result.test @@ -1,4 +1,4 @@ -trait TraitObject extends java.lang.Object with scala.AnyRef { +trait TraitObject extends java.lang.Object { def $init$() : scala.Unit = { /* compiled code */ } def foo : scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/typeAnnotations/result.test b/test/files/scalap/typeAnnotations/result.test index fe48e081d3..d28712f12b 100644 --- a/test/files/scalap/typeAnnotations/result.test +++ b/test/files/scalap/typeAnnotations/result.test @@ -1,8 +1,8 @@ -abstract class TypeAnnotations[@scala.specialized R] extends java.lang.Object with scala.AnyRef { +abstract class TypeAnnotations[@scala.specialized R] extends java.lang.Object { def this() = { /* compiled code */ } @scala.specialized val x : scala.Int = { /* compiled code */ } @scala.specialized type T def compose[@scala.specialized A](x : A, y : R) : A = { /* compiled code */ } -}
\ No newline at end of file +} diff --git a/test/files/scalap/valAndVar/result.test b/test/files/scalap/valAndVar/result.test index 287dfa6163..90081acade 100644 --- a/test/files/scalap/valAndVar/result.test +++ b/test/files/scalap/valAndVar/result.test @@ -1,4 +1,4 @@ -class ValAndVar extends java.lang.Object with scala.AnyRef { +class ValAndVar extends java.lang.Object { def this() = { /* compiled code */ } val foo : java.lang.String = { /* compiled code */ } var bar : scala.Int = { /* compiled code */ } diff --git a/test/files/scalap/wildcardType/result.test b/test/files/scalap/wildcardType/result.test index ceb7c9ba7f..28147b6605 100644 --- a/test/files/scalap/wildcardType/result.test +++ b/test/files/scalap/wildcardType/result.test @@ -1,3 +1,3 @@ -class WildcardType extends java.lang.Object with scala.AnyRef { +class WildcardType extends java.lang.Object { def this(f : scala.Function1[scala.Int, _]) = { /* compiled code */ } } |