summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2012-02-13 00:02:39 +0100
committerMartin Odersky <odersky@gmail.com>2012-02-13 00:02:39 +0100
commit52c99f57ef41c436719818b8e3860e3bfbf023e2 (patch)
treec5146f24872b6bc70b65f2d64170d09450673ec5 /test
parent7bcb1f2fc98eb870fcd52d3b01b3381e5ce0f8d1 (diff)
downloadscala-52c99f57ef41c436719818b8e3860e3bfbf023e2.tar.gz
scala-52c99f57ef41c436719818b8e3860e3bfbf023e2.tar.bz2
scala-52c99f57ef41c436719818b8e3860e3bfbf023e2.zip
All steps of value class proposal implemented. Most restrictions are now enforced. Super calls and specialized still missing.
Diffstat (limited to 'test')
-rw-r--r--test/files/neg/anyval-anyref-parent.check15
-rw-r--r--test/files/neg/anyval-anyref-parent.scala7
-rw-r--r--test/files/neg/t3222.check6
-rw-r--r--test/files/pos/anyval-children.scala1
-rw-r--r--test/files/run/Meter.scala21
-rw-r--r--test/files/run/programmatic-main.check27
6 files changed, 53 insertions, 24 deletions
diff --git a/test/files/neg/anyval-anyref-parent.check b/test/files/neg/anyval-anyref-parent.check
index be895867ff..e1903f5fcc 100644
--- a/test/files/neg/anyval-anyref-parent.check
+++ b/test/files/neg/anyval-anyref-parent.check
@@ -1,14 +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
^
-anyval-anyref-parent.scala:9: error: illegal inheritance; superclass Any
+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:10: error: illegal inheritance; superclass AnyVal
+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
^
-three errors found
+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 08568487a9..f927992e59 100644
--- a/test/files/neg/anyval-anyref-parent.scala
+++ b/test/files/neg/anyval-anyref-parent.scala
@@ -1,10 +1,11 @@
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
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/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/run/Meter.scala b/test/files/run/Meter.scala
index 0c30ddd41e..5700025880 100644
--- a/test/files/run/Meter.scala
+++ b/test/files/run/Meter.scala
@@ -10,10 +10,29 @@ trait Printable extends Any { def print: Unit = Console.print(this) }
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.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))
}
diff --git a/test/files/run/programmatic-main.check b/test/files/run/programmatic-main.check
index b5a54f5ea7..9ddd4a6e14 100644
--- a/test/files/run/programmatic-main.check
+++ b/test/files/run/programmatic-main.check
@@ -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