Skip to content

Commit 1ed3867

Browse files
vsalvisVladimirNik
authored andcommitted
Negtests with // error comments
1 parent 4be70a5 commit 1ed3867

37 files changed

+100
-99
lines changed

tests/neg/arrayclone-new.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ object Test extends dotty.runtime.LegacyApp{
77
}
88

99
object ObjectArrayClone{
10-
val it : Array[String] = Array("1", "0");
10+
val it : Array[String] = Array("1", "0"); // error
1111
val cloned = it.clone();
1212
assert(cloned.sameElements(it));
1313
cloned(0) = "0";
@@ -22,7 +22,7 @@ object PolymorphicArrayClone{
2222
assert(it(0) == one)
2323
}
2424

25-
testIt(Array("one", "two"), "one", "two");
25+
testIt(Array("one", "two"), "one", "two"); // error
2626

2727
class Mangler[T: ClassTag](ts : T*){
2828
// this will always be a BoxedAnyArray even after we've unboxed its contents.

tests/neg/assignments.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ object assignments {
1313
x = x + 1
1414
x *= 2
1515

16-
x_= = 2 // should give missing arguments + reassignment to val
16+
x_= = 2 // error should give missing arguments + // error reassignment to val
1717
}
1818

1919
var c = new C
20-
import c._ // should give: prefix is not stable
20+
import c._ // error should give: prefix is not stable
2121
x = x + 1
2222
x *= 2
2323
}

tests/neg/autoTuplingTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import dotty.language.noAutoTupling
22

33
object autoTuplingNeg {
44

5-
val x = Some(1, 2)
5+
val x = Some(1, 2) // error
66

77
x match {
8-
case Some(a, b) => a + b
8+
case Some(a, b) => a + b // error // error // error
99
case None =>
1010
}
1111
}

tests/neg/blockescapesNeg.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
object blockescapesNeg {
22
def m0 = { object Foo { class Bar { val field = 2 }} ; new Foo.Bar }
3-
m0.field
3+
m0.field // error
44
class A[T]
55
def m1 = { val x = 1; new A[x.type]}
66
}

tests/neg/boundspropagation.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ object test2 {
1313

1414

1515
def f(x: Any): Tree[Null] = x match {
16-
case y: Tree[_] => y
16+
case y: Tree[_] => y // error
1717
}
1818
}
1919
object test3 {
2020
class Tree[+T >: Null]
2121

2222

2323
def f(x: Any): Tree[Null] = x match {
24-
case y: Tree[_] => y
24+
case y: Tree[_] => y // error
2525
}
2626
}
2727

@@ -34,11 +34,11 @@ object test4 {
3434
class Tree[-S, -T >: Option[S]]
3535

3636
def g(x: Any): Tree[_, _ <: Option[N]] = x match {
37-
case y: Tree[_, _] => y
37+
case y: Tree[_, _] => y // error
3838
}
3939
}
4040
}
4141

4242
class Test5 {
43-
"": ({ type U = this.type })#U
43+
"": ({ type U = this.type })#U // error // error
4444
}

tests/neg/companions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ object companionsNeg {
88

99
{ object C {
1010
private val p = 1
11-
println(new C().q)
11+
println(new C().q) // error
1212
}}
1313
}
1414

tests/neg/cycles.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class C {
2222

2323
class E {
2424
class F {
25-
type T <: x.type // error: not stable
26-
val z: x.type = ??? // error: not stable
25+
type T <: x.type // old-error: not stable
26+
val z: x.type = ??? // old-error: not stable
2727
}
2828
lazy val x: F#T = ???
2929
}
@@ -37,6 +37,6 @@ class T2 {
3737
type U = X | Int
3838
}
3939
object T12 {
40-
??? : (T1 {})#U // error: conflicting bounds
41-
??? : (T2 {})#U // error: conflicting bounds
40+
??? : (T1 {})#U // old-error: conflicting bounds
41+
??? : (T2 {})#U // old-error: conflicting bounds
4242
}

tests/neg/escapingRefs.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ object O {
33
class B
44
def f[T](x: T, y: T): T = y
55

6-
val x: A = f(new A { }, new B { })
6+
val x: A = f(new A { }, new B { }) // error
77

88
val y = f({ class C { def member: Int = 1 }; new C }, { class C { def member: Int = 1 }; new C })
9-
val z = y.member
9+
val z = y.member // error
1010
}

tests/neg/i0091-infpaths.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ object infpaths {
22

33
object a {
44
trait T { t =>
5-
type M <: t.b.M
5+
type M <: t.b.M // error
66
type T <: a.T
77
val b: t.T
88
}
99
val x: a.T = ???
1010
}
1111

1212
val m1: a.x.M = ???
13-
val m2: a.x.b.M = m1
14-
val m3: a.x.b.b.M = m2
13+
val m2: a.x.b.M = m1 // error
14+
val m3: a.x.b.b.M = m2 // error
1515

1616
}

tests/neg/i0248-inherit-refined.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
object test {
22
class A { type T }
33
type X = A { type T = Int }
4-
class B extends X
4+
class B extends X // error
55
type Y = A & B
6-
class C extends Y
6+
class C extends Y // error
77
type Z = A | B
8-
class D extends Z
9-
abstract class E extends ({ val x: Int })
8+
class D extends Z // error
9+
abstract class E extends ({ val x: Int }) // error
1010
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
object test {
2-
val b: scala.Boolean = null
2+
val b: scala.Boolean = null // error
33
val c: Unit = null
4-
val d: Float = null
5-
val e: AnyVal = null
4+
val d: Float = null // error
5+
val e: AnyVal = null // error
66
}

tests/neg/i0583-skolemize.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ object Test1 {
1212

1313
val xs: List[C[_]] = List(c, d)
1414

15-
xs(0).x = xs(1).x
15+
xs(0).x = xs(1).x // error
1616

1717
}
1818
object Test {
1919
def main(args: Array[String]): Unit = {
2020
val f: ListBuffer[Int] = ListBuffer(1,2)
2121
val g: ListBuffer[Double] = ListBuffer(3.0,4.0)
2222
val lb: ListBuffer[ListBuffer[_]] = ListBuffer(f, g)
23-
lb(0)(0) = lb(1)(0)
23+
lb(0)(0) = lb(1)(0) // error
2424
val x: Int = f(0)
2525
}
2626
}

tests/neg/i39.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
object i39neg {
22

33
trait B {
4-
type D <: { type T }
4+
type D <: { type T } // error
55
def d: D
66
}
77

@@ -11,7 +11,7 @@ object i39neg {
1111
}
1212

1313
val d: bc.D = bc.d
14-
val pd: bc.D = bc.pd
14+
val pd: bc.D = bc.pd // error
1515

1616
// infinite loop in Typer
1717
val asT: d.T = ???

tests/neg/i50-volatile.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ class Test {
33
class Inner
44
}
55
type A <: Base {
6-
type X = String
6+
type X = String // error
77
}
88
type B <: {
9-
type X = Int
9+
type X = Int // error
1010
}
1111
lazy val o: A & B = ???
1212

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

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

1717
def intToString(i: Int): String = xToString(i)
1818
}
1919
object Test2 {
2020

21-
import Test.o._
21+
import Test.o._ // error
2222

2323
def xToString(x: X): String = x
2424

tests/neg/instantiateAbstract.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ object Test {
2424

2525
new TT // error
2626

27-
new A // error
27+
new A
2828

2929
// the following are OK in Typer but would be caught later in RefChecks
3030

@@ -36,3 +36,5 @@ object Test {
3636

3737
object OO extends AA
3838
}
39+
40+
// nopos-error: "A does not conform to its self type B; cannot be instantiated"

tests/neg/over.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ trait T {
44

55
class C extends T {
66

7-
val x = 2
8-
override val y = 2
7+
val x = 2 // error
8+
override val y = 2 // error
99

1010
}
1111

1212
class D extends T {
1313

14-
def x(): String = ""
14+
def x(): String = "" // error
1515

1616
}
1717

tests/neg/privates.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ trait T {
55
}
66

77
class C { self: T =>
8-
foo
9-
bar
8+
foo // error
9+
bar // error
1010
}
1111

tests/neg/subtyping.scala

Lines changed: 3 additions & 3 deletions
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]
8+
implicitly[B#X <:< A#X] // error
99
}
1010
def test2(): Unit = {
11-
val a : { type T; type U } = ???
12-
implicitly[a.T <:< a.U]
11+
val a : { type T; type U } = ??? // error // error
12+
implicitly[a.T <:< a.U] // error
1313
}
1414
}

tests/neg/t1569-failedAvoid.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
object Bug {
66
class C { type T }
77
def foo(x: Int)(y: C)(z: y.T): Unit = {}
8-
foo(3)(new C { type T = String })("hello")
8+
foo(3)(new C { type T = String })("hello") // error
99
}

tests/neg/t1843-variances.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
object Crash {
88
trait UpdateType[A]
9-
case class StateUpdate[+A](updateType : UpdateType[A], value : A)
9+
case class StateUpdate[+A](updateType : UpdateType[A], value : A) // error
1010
case object IntegerUpdateType extends UpdateType[Integer]
1111

1212
//However this method will cause a crash

tests/neg/t2660.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class A[T](x: T) {
2222
object T {
2323
def main(args: Array[String]): Unit = {
2424
implicit def g2h(g: G): H = new H
25-
new A[Int](new H, 23)
25+
new A[Int](new H, 23) // error
2626
// in the context here, either secondary constructor is applicable
2727
// to the other, due to the implicit in scope. So the call is ambiguous.
2828
}
@@ -40,7 +40,7 @@ object X {
4040
object T2 {
4141
def main(args: Array[String]): Unit = {
4242
implicit def g2h(g: G): H = new H
43-
X.f(new H, 23)
43+
X.f(new H, 23) // error
4444
}
4545
}
4646

tests/neg/t2994.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ object Naturals {
77
type a[s[_ <: NAT] <: NAT, z <: NAT] = z
88
}
99
final class SUCC[n <: NAT] extends NAT {
10-
type a[s[_ <: NAT] <: NAT, z <: NAT] = s[n#a[s, z]] // error: not a legal path
10+
type a[s[_ <: NAT] <: NAT, z <: NAT] = s[n#a[s, z]] // old-error: not a legal path
1111
}
1212
type _0 = ZERO
1313
type _1 = SUCC[_0]
@@ -20,9 +20,8 @@ object Naturals {
2020

2121
// crashes scala-2.8.0 beta1
2222
trait MUL[n <: NAT, m <: NAT] extends NAT {
23-
trait curry[n[_[_], _], s[_]] { type f[z <: NAT] = n[s, z] } // can't do double param lists:
24-
// error: `]' expected but `[` found. // error: wrong number of type arguments
25-
type a[s[_ <: NAT] <: NAT, z <: NAT] = n#a[curry[m#a, s]#f, z] // error: not a legal path // error: not a legal path
23+
trait curry[n[_[_], _], s[_]] { type f[z <: NAT] = n[s, z] } // can't do double param lists: // error: `]' expected but `[` found. // error: wrong number of type arguments
24+
type a[s[_ <: NAT] <: NAT, z <: NAT] = n#a[curry[m#a, s]#f, z] // old-error: not a legal path // old-error: not a legal path
2625
}
2726

2827
}

tests/neg/tailcall/t1672b.scala

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

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

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

3333
@annotation.tailrec
34-
def bez : Nothing = {
34+
def bez : Nothing = { // error
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 = {
44+
def bar(i : Int) : Int = { // error
4545
if (i == 0) 0
4646
else 1 + (try {
4747
throw new RuntimeException
4848
} catch {
49-
case _: Throwable => bar(i - 1)
49+
case _: Throwable => bar(i - 1) // error
5050
})
5151
}
5252
}

tests/neg/tailcall/t3275.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
object Test {
2-
@annotation.tailrec def foo() = 5
2+
@annotation.tailrec def foo() = 5 // error
33
}

0 commit comments

Comments
 (0)