Skip to content

Commit a41fa4f

Browse files
committed
Update tests
1 parent eff2f41 commit a41fa4f

12 files changed

+65
-67
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
final class MyAsInstanceOfClass(o: MyAsInstanceOfClass) {
22
val other: MyAsInstanceOfClass = {
3-
if (o.asInstanceOf[MyAsInstanceOfClass].oRef ne null) o // error
4-
else new MyAsInstanceOfClass(this)
3+
if (o.asInstanceOf[MyAsInstanceOfClass].oRef ne null) o
4+
else new MyAsInstanceOfClass(this) // error
55
}
66
val oRef = o
77
}

tests/init/neg/cycle-structure.check

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
-- Error: tests/init/neg/cycle-structure.scala:2:15 --------------------------------------------------------------------
2-
2 | val x1 = b.x // error
3-
| ^^^
4-
| Access field on a value with an unknown initialization status. Calling trace:
5-
| -> case class B(a: A) { [ cycle-structure.scala:7 ]
6-
| ^
7-
| -> val x = A(this) [ cycle-structure.scala:9 ]
8-
| ^^^^^^^
9-
| -> case class A(b: B) { [ cycle-structure.scala:1 ]
10-
| ^
11-
| -> val x1 = b.x // error [ cycle-structure.scala:2 ]
12-
| ^^^
13-
-- Error: tests/init/neg/cycle-structure.scala:8:15 --------------------------------------------------------------------
14-
8 | val x1 = a.x // error
15-
| ^^^
16-
| Access field on a value with an unknown initialization status. Calling trace:
17-
| -> case class B(a: A) { [ cycle-structure.scala:7 ]
18-
| ^
19-
| -> val x = A(this) [ cycle-structure.scala:9 ]
20-
| ^^^^^^^
21-
| -> case class A(b: B) { [ cycle-structure.scala:1 ]
22-
| ^
23-
| -> val x = B(this) [ cycle-structure.scala:3 ]
24-
| ^^^^^^^
25-
| -> case class B(a: A) { [ cycle-structure.scala:7 ]
26-
| ^
27-
| -> val x1 = a.x // error [ cycle-structure.scala:8 ]
28-
| ^^^
1+
-- Error: tests/init/neg/cycle-structure.scala:9:13 --------------------------------------------------------------------
2+
9 | val x = A(this) // error
3+
| ^^^^^^^
4+
| Unsafe leaking of uninitialized value: the leaked value is used. Calling trace:
5+
| -> case class B(a: A) { [ cycle-structure.scala:7 ]
6+
| ^
7+
| -> val x = A(this) // error [ cycle-structure.scala:9 ]
8+
| ^^^^^^^
9+
|
10+
| The leaked uninitialized value is used as follows:
11+
| -> case class A(b: B) { [ cycle-structure.scala:1 ]
12+
| ^
13+
| -> val x1 = b.x [ cycle-structure.scala:2 ]
14+
| ^^^
15+
-- Error: tests/init/neg/cycle-structure.scala:3:13 --------------------------------------------------------------------
16+
3 | val x = B(this) // error
17+
| ^^^^^^^
18+
| Unsafe leaking of uninitialized value: the leaked value is used. Calling trace:
19+
| -> case class A(b: B) { [ cycle-structure.scala:1 ]
20+
| ^
21+
| -> val x = B(this) // error [ cycle-structure.scala:3 ]
22+
| ^^^^^^^
23+
|
24+
| The leaked uninitialized value is used as follows:
25+
| -> case class B(a: A) { [ cycle-structure.scala:7 ]
26+
| ^
27+
| -> val x1 = a.x [ cycle-structure.scala:8 ]
28+
| ^^^

tests/init/neg/cycle-structure.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
case class A(b: B) {
2-
val x1 = b.x // error
3-
val x = B(this)
2+
val x1 = b.x
3+
val x = B(this) // error
44
val y = x.a
55
}
66

77
case class B(a: A) {
8-
val x1 = a.x // error
9-
val x = A(this)
8+
val x1 = a.x
9+
val x = A(this) // error
1010
val h = x.b
1111
}

tests/init/neg/cycle.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
class A(x: B) {
2-
println(x.b) // error
3-
val a = new B(this)
2+
println(x.b)
3+
val a = new B(this) // error
44
val d = a.b
55
}
66

77
class B(x: A) {
8-
println(x.a) // error
9-
val b = new A(this)
8+
println(x.a)
9+
val b = new A(this) // error
1010
val d = b.a
1111
}

tests/init/neg/early-promote5.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
abstract class A {
2-
bar(this) // error
2+
bar(this)
33
def bar(x: A): Unit
44
}
55

@@ -14,12 +14,11 @@ class M(val o: Outer, c: Container) extends A with o.B
1414

1515
class Container {
1616
val o = new Outer
17-
val m = new M(o, this)
17+
val m = new M(o, this) // error
1818
val s = "hello"
1919
}
2020

2121
class Dummy {
2222
val m: Int = n + 4
2323
val n: Int = 10 // error
2424
}
25-

tests/init/neg/i15363.check

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
-- Warning: tests/init/neg/i15363.scala:3:10 -----------------------------------
1+
-- Error: tests/init/neg/i15363.scala:3:10 -----------------------------------------------------------------------------
22
3 | val b = new B(this) // error
33
| ^^^^^^^^^^^
4-
|Unsafe leaking of uninitialized values: the leaked value is used. Calling trace:
5-
|-> class A: [ i15363.scala:1 ]
6-
| ^
7-
|-> val b = new B(this) // error [ i15363.scala:3 ]
8-
| ^^^^^^^^^^^
4+
| Unsafe leaking of uninitialized value: the leaked value is used. Calling trace:
5+
| -> class A: [ i15363.scala:1 ]
6+
| ^
7+
| -> val b = new B(this) // error [ i15363.scala:3 ]
8+
| ^^^^^^^^^^^
99
|
10-
|The leaked uninitialized value is used as follows:
11-
|-> class B(a: A): [ i15363.scala:7 ]
12-
| ^
13-
|-> val x = a.m [ i15363.scala:8 ]
14-
| ^^^
15-
1 warning found
10+
| The leaked uninitialized value is used as follows:
11+
| -> class B(a: A): [ i15363.scala:7 ]
12+
| ^
13+
| -> val x = a.m [ i15363.scala:8 ]
14+
| ^^^

tests/init/neg/secondary-ctor.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class A(b: B, x: Int) {
22
def this(b: B) = {
33
this(b, 5)
4-
println(b.n) // error
4+
println(b.n)
55
}
66
}
77

@@ -15,5 +15,5 @@ class C(b: B) extends A(b) {
1515

1616
class D {
1717
val b = new B(this)
18-
val c = new C(b, 5)
18+
val c = new C(b, 5) // error
1919
}

tests/init/neg/secondary-ctor2.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class A(b: B, x: Int) {
22
def this(b: B) = {
33
this(b, 5)
44
class Inner() {
5-
def foo() = println(b.n) // error: calling method on cold
5+
def foo() = println(b.n)
66
}
77
Inner().foo()
88

@@ -21,5 +21,5 @@ class C(b: B) extends A(b) {
2121

2222
class D {
2323
val b = new B(this)
24-
val c = new C(b, 5)
24+
val c = new C(b, 5) // error
2525
}

tests/init/neg/secondary-ctor3.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def foo() =
77
def this(b: B) = {
88
this(b, 5)
99
class Inner() {
10-
def foo() = println(b.n) // error
10+
def foo() = println(b.n)
1111
}
1212
Inner().foo()
1313

@@ -35,5 +35,5 @@ def foo() =
3535

3636
class D {
3737
val b = new B(this)
38-
val c = new C(b, 5)
38+
val c = new C(b, 5) // error
3939
}

tests/init/neg/soundness1.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ object Test2:
1919

2020
object Test3:
2121
class A(b: B) {
22-
println(b.a2) // error
23-
val b2 = new B(this)
22+
println(b.a2)
23+
val b2 = new B(this) // error
2424
}
2525

2626
class B(a: A) {
27-
println(a.b2) // error
28-
val a2 = new A(this)
27+
println(a.b2)
28+
val a2 = new A(this) // error
2929
}

tests/init/neg/soundness2.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
class C(c: C) {
2-
val d = c.c2 // error
3-
val c2 = new C(this)
2+
val d = c.c2
3+
val c2 = new C(this) // error
44
}

tests/init/neg/soundness6.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class C(c: C) {
2-
println(c.n) // error
3-
val c2 = new C(this)
2+
println(c.n)
3+
val c2 = new C(this) // error
44
val n = 10
55
}

0 commit comments

Comments
 (0)