summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-01-30 12:42:26 -0800
committerPaul Phillips <paulp@improving.org>2012-01-30 22:18:25 -0800
commita9eb9c5b69071a944d2a5225aa320babdf33ad42 (patch)
tree52c6353685c24c2101f8a963a66068a703405584 /test/files
parent74a252e668959dd2cf4808132473d8b15bb606af (diff)
downloadscala-a9eb9c5b69071a944d2a5225aa320babdf33ad42.tar.gz
scala-a9eb9c5b69071a944d2a5225aa320babdf33ad42.tar.bz2
scala-a9eb9c5b69071a944d2a5225aa320babdf33ad42.zip
More work on inline classes.
Fail compile if AnyVal is inherited by a trait, a non-@inline class, or a class with an AnyRef parent somewhere. Added tests. Added logging, like [log extmethods] Inline class class Bippy spawns extension method. Old: def getClass: Class[_ <: Bippy] New: final def extension$getClass($this: Bippy): Class[_ <: Bippy] Fixed what I hope was a bug in ExtensionMethods where the original method params were dropped. Since adding a NonNull parent was also inflicting an AnyRef on AnyVal subclasses, suppressed that for those. Had the bright idea that AnyVal could extend NotNull. It doesn't seem to accomplish much, but then, I don't think NotNull accomplishes much. Still, maybe it's time to restrict the ways one can use AnyVal so one can't do this: scala> var x: AnyVal = _ x: AnyVal = null
Diffstat (limited to 'test/files')
-rw-r--r--test/files/neg/anyval-children-2.check4
-rw-r--r--test/files/neg/anyval-children-2.scala1
-rw-r--r--test/files/neg/anyval-children.check26
-rw-r--r--test/files/neg/anyval-children.scala14
-rw-r--r--test/files/pos/anyval-children.scala2
5 files changed, 46 insertions, 1 deletions
diff --git a/test/files/neg/anyval-children-2.check b/test/files/neg/anyval-children-2.check
new file mode 100644
index 0000000000..cb327faeeb
--- /dev/null
+++ b/test/files/neg/anyval-children-2.check
@@ -0,0 +1,4 @@
+anyval-children-2.scala:1: error: Only @inline 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
new file mode 100644
index 0000000000..4034eb22dd
--- /dev/null
+++ b/test/files/neg/anyval-children-2.scala
@@ -0,0 +1 @@
+@inline trait NotOkDingus1 extends AnyVal // fail
diff --git a/test/files/neg/anyval-children.check b/test/files/neg/anyval-children.check
new file mode 100644
index 0000000000..cbb5a2b1d1
--- /dev/null
+++ b/test/files/neg/anyval-children.check
@@ -0,0 +1,26 @@
+anyval-children.scala:7: error: illegal inheritance; superclass Bippy
+ is not a subclass of the superclass Object
+ of the mixin trait ScalaObject
+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: illegal inheritance; superclass Bippy
+ is not a subclass of the superclass Object
+ of the mixin trait ScalaObject
+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: illegal inheritance; superclass Bippy
+ is not a subclass of the superclass Object
+ of the mixin trait ScalaObject
+@inline class NotOkBippy3 extends Bippy with Immutable //fail
+ ^
+5 errors found
diff --git a/test/files/neg/anyval-children.scala b/test/files/neg/anyval-children.scala
new file mode 100644
index 0000000000..5a6109f786
--- /dev/null
+++ b/test/files/neg/anyval-children.scala
@@ -0,0 +1,14 @@
+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/pos/anyval-children.scala b/test/files/pos/anyval-children.scala
index 7a2eda8b3f..4ef10a094f 100644
--- a/test/files/pos/anyval-children.scala
+++ b/test/files/pos/anyval-children.scala
@@ -1 +1 @@
-class Bippy extends AnyVal \ No newline at end of file
+@inline class Bippy extends AnyVal \ No newline at end of file