Skip to content

Commit e3345de

Browse files
committed
Negtests with // error comments
1 parent bf6d805 commit e3345de

39 files changed

+120
-118
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: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
class Foo[T <: U, U <: T]
1+
class Foo[T <: U, U <: T] // error
22

3-
class Bar[T >: T]
3+
class Bar[T >: T] // error
44

55
class A {
66
val x: T = ???
7-
type T <: x.type
7+
type T <: x.type // error
88
}
99

1010
class B {
11-
type T <: x.type
11+
type T <: x.type // error
1212
val x: T = ???
1313
}
1414

1515
class C {
1616
val x: D#T = ???
1717
class D {
18-
type T <: x.type
18+
type T <: x.type // error
1919
val z: x.type = ???
2020
}
2121
}
2222

2323
class E {
2424
class F {
2525
type T <: x.type
26-
val z: x.type = ???
26+
val z: x.type = ??? // error
2727
}
2828
val x: F#T = ???
2929
}
3030

3131
class T1 {
32-
type X = (U, U) // cycle
32+
type X = (U, U) // cycle // error
3333
type U = X & Int
3434
}
3535
class T2 {
36-
type X = (U, U) // cycle
36+
type X = (U, U) // cycle // error
3737
type U = X | Int
3838
}
3939
object T12 {

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 @@ object 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/overrides.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
}
99
trait FooB extends FooA {
1010
type A <: Ax;
11-
trait Ax extends super.Ax { def xxx : Int; }
11+
trait Ax extends super.Ax { def xxx : Int; } // error
1212
abstract class InnerB extends InnerA {
1313
// type B <: A;
1414
val a : A = doB;
@@ -31,7 +31,7 @@ package p2 { // all being in the same package compiles fine
3131
}
3232

3333
abstract class T3 extends T2 {
34-
class A {
34+
class A { // error
3535
bug()
3636
}
3737
}
@@ -45,7 +45,7 @@ class A[T] {
4545

4646
class B extends A[Int] {
4747

48-
def f(x: Int)(y: Int) = y
48+
def f(x: Int)(y: Int) = y // error
4949

5050
f(2)()
5151

@@ -55,7 +55,7 @@ class X {
5555
def f: A[Int] = ???
5656
}
5757
class Y extends X {
58-
def f: A[Int] = ???
58+
def f: A[Int] = ??? // error
5959
}
6060

6161

@@ -66,18 +66,18 @@ class X1 {
6666
def f(): A1 = ???
6767
}
6868
class Y1 extends X1 {
69-
override def f(): B1 = ???
69+
override def f(): B1 = ??? // error
7070
}
7171

7272
class X2 {
7373
type T = A1
7474
}
7575
class Y2 extends X2 {
76-
type T = B1
76+
type T = B1 // error
7777
}
7878

7979
class X3 {
80-
override type T = A1
80+
override type T = A1 // error
8181
}
8282

8383
package p3 {
@@ -97,14 +97,14 @@ trait TOverrider { this: TCommon =>
9797
override def f = "in TOverrider" // The overridden self-type member...
9898
}
9999

100-
class C2 extends C1 with TOverrider // ... fails to override, here.
100+
class C2 extends C1 with TOverrider // ... fails to override, here. // error
101101

102102
}
103103

104104
package p4 {
105105

106106
abstract class C[T] { def head: T }
107-
case class D[T](head: Int) extends C[T]
107+
case class D[T](head: Int) extends C[T] // error
108108

109109
}
110110

@@ -114,10 +114,10 @@ class A {
114114
}
115115

116116
class B extends A {
117-
override val m: Int = 42
117+
override val m: Int = 42 // error
118118
}
119119

120120
class C extends A {
121-
override def m: Int = 42
121+
override def m: Int = 42 // error
122122
}
123123
}

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

0 commit comments

Comments
 (0)