Skip to content

Commit 955b04a

Browse files
committed
Adapt neg tests to new neg tests checks
1 parent 5fc321f commit 955b04a

18 files changed

+56
-56
lines changed

tests/neg/abstract-override.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
trait T { def foo: Int }
2-
trait T1 extends T { override def foo = super.foo }
3-
trait T2 extends T { override def foo = super.foo }
2+
trait T1 extends T { override def foo = super.foo } // error: method foo in trait T is accessed from super.
3+
trait T2 extends T { override def foo = super.foo } // error: method foo in trait T is accessed from super.
44
object Test extends T2 with T1 {
55
def main(args: Array[String]) = {
66
assert(foo == 3)

tests/neg/amp.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ object Test extends dotty.runtime.LegacyApp {
22

33
def foo() = {
44
def f: Int = 1
5-
val x = f _
5+
val x = f _ // error: not a function: => Int(f)
66
x
77
}
88

99
def bar(g: => Int) = {
10-
g _
10+
g _ // error: not a function: => Int(g)
1111
}
1212

13-
Console.println((bar{ Console.println("g called"); 42 })())
14-
Console.println(foo()())
13+
Console.println((bar{ Console.println("g called"); 42 })()) // error: method bar in object Test$ does not take more parameters
14+
Console.println(foo()()) // error: method foo in object Test$ does not take more parameters
1515
}

tests/neg/autoTuplingTest.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import dotty.language.noAutoTupling
22

3-
object autoTuplingNeg {
3+
object autoTuplingNeg2 {
44

5-
val x = Some(1, 2) // error
5+
val x = Some(1, 2) // error: too many arguments for method apply: (x: A)Some[A]
66

77
x match {
8-
case Some(a, b) => a + b // error // error // error
8+
case Some(a, b) => a + b // error: wrong number of argument patterns for Some // error: not found: b
99
case None =>
1010
}
1111
}

tests/neg/bounds.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
object Test {
22
def g[B >: String <: Int](x: B): Int = x
33
def main(args: Array[String]): Unit = {
4-
g("foo")
4+
g("foo") // error: Type argument String' does not conform to upper bound Int
55
}
66
def baz[X >: Y, Y <: String](x: X, y: Y) = (x, y)
77

8-
baz[Int, String](1, "abc")
8+
baz[Int, String](1, "abc") // error: Type argument Int does not conform to lower bound Y
99

1010
}

tests/neg/final-sealed.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
final class A
2-
class B extends A
3-
class C extends Option[Int]
2+
class B extends A // error: cannot extend final class A
3+
class C extends Option[Int] // error: cannot extend sealed class Option in different compilation unit
44

tests/neg/firstError.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.
1+
. // error: expected class or object definition
22

3-
\u890u3084eu
3+
\u890u3084eu // error: error in unicode escape // error: illegal character '\uffff'
44

tests/neg/i1050c.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ object Import {
44
trait B { type L >: Any}
55
trait U {
66
lazy val p: B
7-
locally { val x: p.L = ??? } // error: nonfinal lazy
7+
locally { val x: p.L = ??? } // old-error: nonfinal lazy
88
locally {
9-
import p._
10-
val x: L = ??? // error: nonfinal lazy
9+
import p._ // error: Import.B(U.this.p) is not a legal path
10+
val x: L = ??? // old-error: nonfinal lazy
1111
}
1212
}
1313
}

tests/neg/i324.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class O
22
object O {
3-
val x: this.type = OO.this
4-
val y: O = OO.this
3+
val x: this.type = OO.this // error: OO is not an enclosing class
4+
val y: O = OO.this // error: OO is not an enclosing class
55
}

tests/neg/i50-volatile.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ class Test {
1010
}
1111
lazy val o: A & B = ???
1212

13-
class Client extends o.Inner // error // error
13+
class Client extends o.Inner // old-error // old-error
1414

15-
def xToString(x: o.X): String = x // error
15+
def xToString(x: o.X): String = x // old-error
1616

1717
def intToString(i: Int): String = xToString(i)
1818
}
+8-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
class Foo {
2-
class B(val a: Int) extends AnyVal // error
2+
class B(val a: Int) extends AnyVal // error: value class may not be a member of another class
33
}
44

55
class VCwithBadMembers(val a: Int) extends AnyVal {
6-
def this() = this(1) // error
7-
var x = 0 // error
8-
val y = 2 // error
9-
println("hi") // error
6+
def this() = this(1) // error: value class may not define secondary constructor
7+
var x = 0 // error: value class may not define non-parameter field
8+
val y = 2 // error: value class may not define non-parameter field
9+
println("hi") // error: value class may not contain initialization statements
1010
}
1111

1212
object Test {
1313
class B(val a: Int) extends AnyVal // ok
1414
def f = {
15-
class C(val a: Int) extends AnyVal // error
15+
class C(val a: Int) extends AnyVal // error: value class may not be a local class
1616
new C(1)
1717
}
18-
class B1(val b: Int) extends B(b)
19-
// class D extends B( { class E(val a: Int) extends AnyVal; new E(1) } ) // error
18+
class B1(val b: Int) extends B(b) // error: cannot extend final class B
19+
// class D extends B( { class E(val a: Int) extends AnyVal; new E(1) } )
2020
}
2121

2222

tests/neg/i871.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
trait Message {
2-
def first(x: Int)
3-
def second
2+
def first(x: Int) // error: missing return type
3+
def second // error: missing return type
44
1
55
}

tests/neg/partialApplications.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
object Test2 {
22
type Histogram = Map[_, Int] // this is now an existential type!
33

4-
type StringlyHistogram = Histogram[_ >: String] // Error: Test2.Histogram does not take type parameters
4+
type StringlyHistogram = Histogram[_ >: String] // error: Test2.Histogram does not take type parameters
55

6-
val xs: Histogram[String] = Map[String, Int]() // Error: Test2.Histogram does not take type parameters
6+
val xs: Histogram[String] = Map[String, Int]() // error: Test2.Histogram does not take type parameters
77

8-
val ys: StringlyHistogram[String] = xs // Error: Test2.StringlyHistogram does not take type parameters
8+
val ys: StringlyHistogram[String] = xs // error: Test2.StringlyHistogram does not take type parameters
99

1010
val zs: StringlyHistogram = xs
1111

tests/neg/selfInheritance.scala

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ class C { self: B =>
1111

1212
}
1313

14-
class D extends A // error
14+
class D extends A // error: illegal inheritance: self type D of class D does not conform to self type B of parent class A
1515

16-
class E extends T // error
16+
class E extends T // error: illegal inheritance: self type E of class E does not conform to self type B of parent trait T
1717

1818
object Test {
1919

2020
new B() {}
2121

22-
new A() {} // error
22+
new A() {} // error: illegal inheritance: self type A{...} of anonymous class A{...} does not conform to self type B of parent class A
2323

24-
object O extends A // error
24+
object O extends A // error: illegal inheritance: self type Test.O.type of object O$ does not conform to self type B of parent class A
2525

26-
object M extends C // error
26+
object M extends C // error: illegal inheritance: self type Test.M.type of object M$ does not conform to self type B of parent class C
2727

2828
}
2929

30-
trait X { self: Y => }
30+
trait X { self: Y => } // error: missing requirement: self type Y & X of trait X does not conform to self type Z of required trait Y
3131
trait Y { self: Z => }
3232
trait Z

tests/neg/selfreq.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ trait X { self: Y => // error: cannot resolve reference to type (Y & X)(X.this)
22

33
type T <: self.U
44

5-
def foo(x: T): T // error: cannot resolve reference to type (Y & X)(X.this).V
5+
def foo(x: T): T // old-error: cannot resolve reference to type (Y & X)(X.this).V
66
def foo(x: String): String
77

88
}

tests/neg/singletons.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ object Test {
33
val x = 42
44
val z: 42 = x // error: x is not final
55

6-
val n: null = null // error: Null is not a legal singleton type
6+
val n: null = null // error: Null is not a legal singleton type // error: only classes can have declared but undefined members
77

8-
val sym: 'sym = 'sym // error: Symbol is not a legal singleton type
8+
val sym: 'sym = 'sym // error: Symbol is not a legal singleton type // error: only classes can have declared but undefined members
99

10-
val foo: s"abc" = "abc" // error: not a legal singleton type
10+
val foo: s"abc" = "abc" // error: not a legal singleton type // error: only classes can have declared but undefined members
1111
}

tests/neg/subtyping.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ class A extends B
55

66
object Test {
77
def test1(): Unit = {
8-
implicitly[B#X <:< A#X] // error
9-
}
8+
implicitly[B#X <:< A#X] // error: no implicit argument
9+
} // error: no implicit argument
1010
def test2(): Unit = {
11-
val a : { type T; type U } = ??? // error // error
12-
implicitly[a.T <:< a.U] // error
11+
val a : { type T; type U } = ??? // error // error
12+
implicitly[a.T <:< a.U] // error: no implicit argument
1313
}
1414
}

tests/neg/tailcall/t1672b.scala

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
object Test1772B {
22
@annotation.tailrec
3-
def bar : Nothing = { // error
3+
def bar : Nothing = { // error: TailRec optimisation not applicable
44
try {
55
throw new RuntimeException
66
} catch {
@@ -11,7 +11,7 @@ object Test1772B {
1111
}
1212

1313
@annotation.tailrec
14-
def baz : Nothing = { // error
14+
def baz : Nothing = { // error: TailRec optimisation not applicable
1515
try {
1616
throw new RuntimeException
1717
} catch {
@@ -22,7 +22,7 @@ object Test1772B {
2222
}
2323

2424
@annotation.tailrec
25-
def boz : Nothing = { // error
25+
def boz : Nothing = { // error: TailRec optimisation not applicable
2626
try {
2727
throw new RuntimeException
2828
} catch {
@@ -31,7 +31,7 @@ object Test1772B {
3131
}
3232

3333
@annotation.tailrec
34-
def bez : Nothing = { // error
34+
def bez : Nothing = { // error: TailRec optimisation not applicable
3535
try {
3636
bez
3737
} finally {
@@ -41,12 +41,12 @@ object Test1772B {
4141

4242
// the `liftedTree` local method will prevent a tail call here.
4343
@annotation.tailrec
44-
def bar(i : Int) : Int = { // error
44+
def bar(i : Int) : Int = { // error: TailRec optimisation not applicable
4545
if (i == 0) 0
4646
else 1 + (try {
4747
throw new RuntimeException
4848
} catch {
49-
case _: Throwable => bar(i - 1) // error
49+
case _: Throwable => bar(i - 1) // old-error
5050
})
5151
}
5252
}

tests/pos/autoTuplingTest.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ object autoTupling {
33
val x = Some(1, 2) // error when running with -language:noAutoTupling
44

55
x match {
6-
case Some(a, b) => a + b // error // error // error when running with -language:noAutoTupling
6+
case Some(a, b) => a + b // error // error when running with -language:noAutoTupling
77
case None =>
88
}
99
}

0 commit comments

Comments
 (0)