summaryrefslogtreecommitdiff
path: root/test/files/neg
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/neg')
-rw-r--r--test/files/neg/anytrait.check7
-rw-r--r--test/files/neg/anytrait.scala10
-rw-r--r--test/files/neg/anyval-anyref-parent.check23
-rw-r--r--test/files/neg/anyval-anyref-parent.scala12
-rw-r--r--test/files/neg/anyval-sealed.check12
-rw-r--r--test/files/neg/anyval-sealed.flags1
-rw-r--r--test/files/neg/anyval-sealed.scala6
-rw-r--r--test/files/neg/overloaded-unapply.check (renamed from test/files/neg/t960.check)6
-rw-r--r--test/files/neg/overloaded-unapply.scala (renamed from test/files/neg/t960.scala)0
-rw-r--r--test/files/neg/override-object-no.check12
-rw-r--r--test/files/neg/t0699.check6
-rw-r--r--test/files/neg/t0764.check2
-rw-r--r--test/files/neg/t2641.check6
-rw-r--r--test/files/neg/t3691.check4
-rw-r--r--test/files/neg/t464-neg.check4
-rw-r--r--test/files/neg/t4877.check2
-rw-r--r--test/files/neg/t5060.check4
-rw-r--r--test/files/neg/t5529.check4
-rw-r--r--test/files/neg/t5572.check11
-rw-r--r--test/files/neg/t5572.scala23
-rw-r--r--test/files/neg/t664.check4
-rw-r--r--test/files/neg/t900.check4
-rw-r--r--test/files/neg/valueclasses-doubledefs.check7
-rw-r--r--test/files/neg/valueclasses-doubledefs.scala6
-rw-r--r--test/files/neg/valueclasses.check46
-rw-r--r--test/files/neg/valueclasses.scala54
-rw-r--r--test/files/neg/variances.check2
27 files changed, 226 insertions, 52 deletions
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
new file mode 100644
index 0000000000..fe20e5de81
--- /dev/null
+++ b/test/files/neg/anyval-anyref-parent.check
@@ -0,0 +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: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
new file mode 100644
index 0000000000..f927992e59
--- /dev/null
+++ b/test/files/neg/anyval-anyref-parent.scala
@@ -0,0 +1,12 @@
+trait Foo1 extends Any
+trait Foo2 extends AnyVal // fail
+trait Foo3 extends AnyRef
+
+class Bar1 extends Any // fail
+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-sealed.check b/test/files/neg/anyval-sealed.check
deleted file mode 100644
index 48a457b496..0000000000
--- a/test/files/neg/anyval-sealed.check
+++ /dev/null
@@ -1,12 +0,0 @@
-anyval-sealed.scala:2: error: match is not exhaustive!
-missing combination Byte
-missing combination Char
-missing combination Double
-missing combination Float
-missing combination Long
-missing combination Short
-missing combination Unit
-
- def f(x: AnyVal) = x match {
- ^
-one error found
diff --git a/test/files/neg/anyval-sealed.flags b/test/files/neg/anyval-sealed.flags
deleted file mode 100644
index 85d8eb2ba2..0000000000
--- a/test/files/neg/anyval-sealed.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xfatal-warnings
diff --git a/test/files/neg/anyval-sealed.scala b/test/files/neg/anyval-sealed.scala
deleted file mode 100644
index 232a183479..0000000000
--- a/test/files/neg/anyval-sealed.scala
+++ /dev/null
@@ -1,6 +0,0 @@
-class A {
- def f(x: AnyVal) = x match {
- case _: Boolean => 1
- case _: Int => 2
- }
-} \ No newline at end of file
diff --git a/test/files/neg/t960.check b/test/files/neg/overloaded-unapply.check
index 603b1cb032..1da93f6939 100644
--- a/test/files/neg/t960.check
+++ b/test/files/neg/overloaded-unapply.check
@@ -1,13 +1,13 @@
-t960.scala:18: error: ambiguous reference to overloaded definition,
+overloaded-unapply.scala:18: error: ambiguous reference to overloaded definition,
both method unapply in object List of type [a](xs: List[a])Option[Null]
and method unapply in object List of type [a](xs: List[a])Option[(a, List[a])]
match argument types (List[a])
case List(x, xs) => 7
^
-t960.scala:22: error: cannot resolve overloaded unapply
+overloaded-unapply.scala:22: error: cannot resolve overloaded unapply
case List(x, xs) => 7
^
-t960.scala:12: error: method unapply is defined twice in t960.scala
+overloaded-unapply.scala:12: error: method unapply is defined twice in overloaded-unapply.scala
def unapply[a](xs: List[a]): Option[Null] = xs match {
^
three errors found
diff --git a/test/files/neg/t960.scala b/test/files/neg/overloaded-unapply.scala
index 36909626c1..36909626c1 100644
--- a/test/files/neg/t960.scala
+++ b/test/files/neg/overloaded-unapply.scala
diff --git a/test/files/neg/override-object-no.check b/test/files/neg/override-object-no.check
index 6e028d0add..f9fb37381b 100644
--- a/test/files/neg/override-object-no.check
+++ b/test/files/neg/override-object-no.check
@@ -1,13 +1,13 @@
override-object-no.scala:14: error: overriding object Bar in trait Foo with object Bar in trait Foo2:
an overriding object must conform to the overridden object's class bound;
- found : case1.Bippy with ScalaObject
- required: case1.Bippy with case1.Bippo with ScalaObject
+ found : case1.Bippy
+ required: case1.Bippy with case1.Bippo
override object Bar extends Bippy { // err
^
override-object-no.scala:21: error: overriding object Bar in trait Quux1 with object Bar in trait Quux2:
an overriding object must conform to the overridden object's class bound;
- found : Object with ScalaObject{def g: String}
- required: Object with ScalaObject{def g: Int}
+ found : Object{def g: String}
+ required: Object{def g: Int}
trait Quux2 extends Quux1 { override object Bar { def g = "abc" } } // err
^
override-object-no.scala:25: error: overriding object Bar in trait Quux3 of type object Quux4.this.Bar;
@@ -16,8 +16,8 @@ override-object-no.scala:25: error: overriding object Bar in trait Quux3 of type
^
override-object-no.scala:43: error: overriding object A in class Foo with object A in class P2:
an overriding object must conform to the overridden object's class bound;
- found : case2.Bar[List[String]] with ScalaObject
- required: case2.Bar[Traversable[String]] with ScalaObject
+ found : case2.Bar[List[String]]
+ required: case2.Bar[Traversable[String]]
override object A extends Bar[List[String]] // err
^
four errors found
diff --git a/test/files/neg/t0699.check b/test/files/neg/t0699.check
index 45d3e849cc..c944da8c10 100644
--- a/test/files/neg/t0699.check
+++ b/test/files/neg/t0699.check
@@ -1,10 +1,10 @@
-B.scala:2: error: illegal inheritance from sealed trait T: t0699/B.scala != t0699/A.scala
+B.scala:2: error: illegal inheritance from sealed trait T
trait T1 extends A.T
^
-B.scala:3: error: illegal inheritance from sealed class C: t0699/B.scala != t0699/A.scala
+B.scala:3: error: illegal inheritance from sealed class C
trait T2 extends A.C
^
-B.scala:4: error: illegal inheritance from sealed class C: t0699/B.scala != t0699/A.scala
+B.scala:4: error: illegal inheritance from sealed class C
class C1 extends A.C
^
three errors found
diff --git a/test/files/neg/t0764.check b/test/files/neg/t0764.check
index 0788db7f6e..e14c7705b8 100644
--- a/test/files/neg/t0764.check
+++ b/test/files/neg/t0764.check
@@ -1,5 +1,5 @@
t0764.scala:13: error: type mismatch;
- found : Object with Node{type T = _1.type} where val _1: Node{type T = NextType}
+ found : Node{type T = _1.type} where val _1: Node{type T = NextType}
required: Node{type T = Main.this.AType}
new Main[AType]( (value: AType).prepend )
^
diff --git a/test/files/neg/t2641.check b/test/files/neg/t2641.check
index 9e2f02ac47..909f4f0cf3 100644
--- a/test/files/neg/t2641.check
+++ b/test/files/neg/t2641.check
@@ -9,11 +9,7 @@ t2641.scala:17: error: illegal inheritance;
self-type ManagedSeq does not conform to scala.collection.TraversableView[A,ManagedSeqStrict[A]]'s selftype scala.collection.TraversableView[A,ManagedSeqStrict[A]]
with TraversableView[A, ManagedSeqStrict[A]]
^
-t2641.scala:16: error: illegal inheritance;
- self-type ManagedSeq does not conform to ScalaObject's selftype ScalaObject
- extends ManagedSeqStrict[A]
- ^
t2641.scala:27: error: value managedIterator is not a member of ManagedSeq
override def managedIterator = self.managedIterator slice (from, until)
^
-5 errors found
+four errors found
diff --git a/test/files/neg/t3691.check b/test/files/neg/t3691.check
index cd7b440dce..bdf6c268b2 100644
--- a/test/files/neg/t3691.check
+++ b/test/files/neg/t3691.check
@@ -1,10 +1,10 @@
t3691.scala:4: error: type mismatch;
- found : Object with Test.A[String]
+ found : Test.A[String]
required: AnyRef{type A[x]}
val b = (new A[String]{}): { type A[x] } // not ok
^
t3691.scala:5: error: type mismatch;
- found : Object with Test.A[String]
+ found : Test.A[String]
required: AnyRef{type A}
val c = (new A[String]{}): { type A } // not ok
^
diff --git a/test/files/neg/t464-neg.check b/test/files/neg/t464-neg.check
index aea1987b2e..e822e7fb6b 100644
--- a/test/files/neg/t464-neg.check
+++ b/test/files/neg/t464-neg.check
@@ -1,7 +1,7 @@
t464-neg.scala:7: error: not found: value f1
f1()
^
-t464-neg.scala:8: error: method f1 in class A cannot be accessed in A with ScalaObject
+t464-neg.scala:8: error: method f1 in class A cannot be accessed in A
super.f1()
^
t464-neg.scala:9: error: value f2 is not a member of B
@@ -10,7 +10,7 @@ t464-neg.scala:9: error: value f2 is not a member of B
t464-neg.scala:10: error: method f3 in class A cannot be accessed in B
f3()
^
-t464-neg.scala:11: error: method f3 in class A cannot be accessed in A with ScalaObject
+t464-neg.scala:11: error: method f3 in class A cannot be accessed in A
super.f3()
^
5 errors found
diff --git a/test/files/neg/t4877.check b/test/files/neg/t4877.check
index 0f72300bb4..a4b1e6a50d 100644
--- a/test/files/neg/t4877.check
+++ b/test/files/neg/t4877.check
@@ -9,7 +9,7 @@ t4877.scala:6: error: type mismatch;
def foo3: AnyRef { def bar(x: Int): Int } = new AnyRef { def bar(x: Int) = "abc" }
^
t4877.scala:7: error: type mismatch;
- found : Object with C{def bar(x: Int): Int}
+ found : C{def bar(x: Int): Int}
required: C{def bar(x: Int): Int; def quux(x: Int): Int}
def foo4: C { def bar(x: Int): Int ; def quux(x: Int): Int } = new C { def bar(x: Int) = 5 }
^
diff --git a/test/files/neg/t5060.check b/test/files/neg/t5060.check
index ab860c9d5b..e71f30ccdb 100644
--- a/test/files/neg/t5060.check
+++ b/test/files/neg/t5060.check
@@ -1,7 +1,7 @@
-t5060.scala:2: error: covariant type T occurs in contravariant position in type => Object with ScalaObject{def contains(x: T): Unit} of value foo0
+t5060.scala:2: error: covariant type T occurs in contravariant position in type => Object{def contains(x: T): Unit} of value foo0
val foo0 = {
^
-t5060.scala:6: error: covariant type T occurs in contravariant position in type => Object with ScalaObject{def contains(x: T): Unit} of method foo1
+t5060.scala:6: error: covariant type T occurs in contravariant position in type => Object{def contains(x: T): Unit} of method foo1
def foo1 = {
^
two errors found
diff --git a/test/files/neg/t5529.check b/test/files/neg/t5529.check
index 78a26aeb50..5d2175fa79 100644
--- a/test/files/neg/t5529.check
+++ b/test/files/neg/t5529.check
@@ -4,9 +4,7 @@ t5529.scala:12: error: File is already defined as class File
t5529.scala:10: error: class type required but test.Test.File found
sealed class Dir extends File { }
^
-t5529.scala:10: error: illegal inheritance; super<none>
- is not a subclass of the superclass Object
- of the mixin trait ScalaObject
+t5529.scala:10: error: test.Test.File does not have a constructor
sealed class Dir extends File { }
^
three errors found
diff --git a/test/files/neg/t5572.check b/test/files/neg/t5572.check
new file mode 100644
index 0000000000..7b1e290861
--- /dev/null
+++ b/test/files/neg/t5572.check
@@ -0,0 +1,11 @@
+t5572.scala:16: error: type mismatch;
+ found : B
+ required: A
+ Z.transf(a, b) match {
+ ^
+t5572.scala:18: error: type mismatch;
+ found : A
+ required: B
+ run(sth, b)
+ ^
+two errors found
diff --git a/test/files/neg/t5572.scala b/test/files/neg/t5572.scala
new file mode 100644
index 0000000000..2da1209c61
--- /dev/null
+++ b/test/files/neg/t5572.scala
@@ -0,0 +1,23 @@
+class A
+class B
+
+trait X
+
+object Z {
+ def transf(a: A, b: B): X = null
+}
+
+class Test {
+
+ def bar(): (A, B)
+
+ def foo {
+ val (b, a) = bar()
+ Z.transf(a, b) match {
+ case sth =>
+ run(sth, b)
+ }
+ }
+
+ def run(x: X, z: B): Unit = ()
+}
diff --git a/test/files/neg/t664.check b/test/files/neg/t664.check
index 43a6bea074..cbdf53daea 100644
--- a/test/files/neg/t664.check
+++ b/test/files/neg/t664.check
@@ -1,7 +1,7 @@
-t664.scala:4: error: type Foo is not a member of test.Test with ScalaObject
+t664.scala:4: error: type Foo is not a member of test.Test
trait Foo extends super.Foo {
^
-t664.scala:5: error: type Bar is not a member of AnyRef with ScalaObject
+t664.scala:5: error: type Bar is not a member of AnyRef
trait Bar extends super.Bar;
^
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/neg/variances.check b/test/files/neg/variances.check
index 4eaab56cef..dc72b05e1e 100644
--- a/test/files/neg/variances.check
+++ b/test/files/neg/variances.check
@@ -4,7 +4,7 @@ variances.scala:4: error: covariant type A occurs in contravariant position in t
variances.scala:14: error: covariant type A occurs in contravariant position in type A of value a
private[this] def setA(a : A) = this.a = a
^
-variances.scala:16: error: covariant type A occurs in invariant position in supertype test.C[A] with ScalaObject of object Baz
+variances.scala:16: error: covariant type A occurs in invariant position in supertype test.C[A] of object Baz
object Baz extends C[A]
^
variances.scala:63: error: covariant type A occurs in contravariant position in type => test.Covariant.T[A]{val m: A => A} of value x