Skip to content

Commit 893892f

Browse files
EnzeXingliufengyun
authored andcommitted
Update tests
1 parent a82a1a6 commit 893892f

11 files changed

+64
-6
lines changed

tests/init/neg/enum-desugared.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
| Cannot prove that the value is fully-initialized. May only use initialized value as method arguments.
1414
|
1515
| The unsafe promotion may cause the following problem:
16-
| Calling the external method method ordinal may cause initialization errors. Calling trace:
16+
| Calling the external method method name may cause initialization errors. Calling trace:
1717
| -> Array(this.LazyErrorId, this.NoExplanationID) // error // error [ enum-desugared.scala:17 ]
18-
| -> def errorNumber: Int = this.ordinal() - 2 [ enum-desugared.scala:8 ]
18+
| -> override def productPrefix: String = this.name() [ enum-desugared.scala:29 ]

tests/init/neg/inner-loop.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Outer { outer =>
22
class Inner extends Outer {
3-
val x = 5 + outer.n // error
3+
val x = 5 + outer.n
44
}
55
val inner = new Inner
66
val n = 6 // error

tests/init/neg/local-warm4.check

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@
66
| -> class A(x: Int) extends Foo(x) { [ local-warm4.scala:6 ]
77
| -> val b = new B(y) [ local-warm4.scala:10 ]
88
| -> class B(x: Int) extends A(x) { [ local-warm4.scala:13 ]
9-
| -> class A(x: Int) extends Foo(x) { [ local-warm4.scala:6 ]
10-
| -> increment() [ local-warm4.scala:9 ]
11-
| -> updateA() [ local-warm4.scala:21 ]
9+
| -> if y < 10 then increment() [ local-warm4.scala:23 ]
10+
| -> updateA() [ local-warm4.scala:21 ]

tests/init/neg/unsound1.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- Error: tests/init/neg/unsound1.scala:2:35 ---------------------------------------------------------------------------
2+
2 | if (m > 0) println(foo(m - 1).a2.n) // error
3+
| ^^^^^^^^^^^^^^^
4+
| Access field A.this.foo(A.this.m.-(1)).a2.n on a value with an unknown initialization status.

tests/init/neg/unsound1.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class A(m: Int) {
2+
if (m > 0) println(foo(m - 1).a2.n) // error
3+
def foo(n: Int): B =
4+
if (n % 2 == 0)
5+
new B(new A(n - 1), foo(n - 1).a1)
6+
else
7+
new B(this, new A(n - 1))
8+
var n: Int = 10
9+
}
10+
11+
class B(val a1: A, val a2: A)

tests/init/neg/unsound2.check

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Error: tests/init/neg/unsound2.scala:5:26 ---------------------------------------------------------------------------
2+
5 | def getN: Int = a.n // error
3+
| ^^^
4+
| Access field B.this.a.n on a value with an unknown initialization status. Calling trace:
5+
| -> println(foo(x).getB) [ unsound2.scala:8 ]
6+
| -> def foo(y: Int): B = if (y > 10) then B(bar(y - 1), foo(y - 1).getN) else B(bar(y), 10) [ unsound2.scala:2 ]

tests/init/neg/unsound2.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
case class A(x: Int) {
2+
def foo(y: Int): B = if (y > 10) then B(bar(y - 1), foo(y - 1).getN) else B(bar(y), 10)
3+
def bar(y: Int): A = if (y > 10) then A(y - 1) else this
4+
class B(a: A, b: Int) {
5+
def getN: Int = a.n // error
6+
def getB: Int = b
7+
}
8+
println(foo(x).getB)
9+
val n: Int = 10
10+
}

tests/init/neg/unsound3.check

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- Error: tests/init/neg/unsound3.scala:10:38 --------------------------------------------------------------------------
2+
10 | if (x < 12) then foo().getC().b else newB // error
3+
| ^^^^^^^^^^^^^^
4+
| Access field C.this.foo().getC().b on a value with an unknown initialization status. Calling trace:
5+
| -> val b = foo() [ unsound3.scala:12 ]

tests/init/neg/unsound3.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class B(c: C) {
2+
def getC() = c
3+
}
4+
5+
class C {
6+
var x = 10
7+
def foo(): B = {
8+
x += 1
9+
val newB = new B(this)
10+
if (x < 12) then foo().getC().b else newB // error
11+
}
12+
val b = foo()
13+
}

tests/init/neg/unsound4.check

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Error: tests/init/neg/unsound4.scala:3:8 ----------------------------------------------------------------------------
2+
3 | val aAgain = foo(5) // error
3+
| ^
4+
| Access non-initialized value aAgain. Calling trace:
5+
| -> val aAgain = foo(5) // error [ unsound4.scala:3 ]
6+
| -> def foo(x: Int): A = if (x < 5) then this else foo(x - 1).aAgain [ unsound4.scala:2 ]

tests/init/neg/unsound4.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class A {
2+
def foo(x: Int): A = if (x < 5) then this else foo(x - 1).aAgain
3+
val aAgain = foo(5) // error
4+
}

0 commit comments

Comments
 (0)