Skip to content

Commit 6cbfd9a

Browse files
committed
Update tests
Fixing inherit-non-hot.check
1 parent ba5f4f0 commit 6cbfd9a

14 files changed

+61
-38
lines changed

tests/init/neg/Desugar.check

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/init/neg/InteractiveDriver.check

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/init/neg/closureLeak.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/init/neg/closureLeak.scala:11:14 -----------------------------------------------------------------------
22
11 | l.foreach(a => a.addX(this)) // error
33
| ^^^^^^^^^^^^^^^^^
4-
| Cannot prove that the value is fully-initialized. May only use initialized value as arguments.
4+
| Cannot prove that the value is fully-initialized. May only use initialized value as arguments.
55
|
6-
| The unsafe promotion may cause the following problem:
7-
| Promote the value under initialization to fully-initialized. May only use initialized value as arguments.
6+
| The unsafe promotion may cause the following problem:
7+
| Cannot prove that the value is fully initialized. May only use initialized value as arguments.

tests/init/neg/cycle-structure.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
-- Error: tests/init/neg/cycle-structure.scala:3:14 --------------------------------------------------------------------
22
3 | val x = B(this) // error
33
| ^^^^
4-
| Promote the value under initialization to fully-initialized. May only use initialized value as arguments.
4+
| Cannot prove that the value is fully initialized. May only use initialized value as arguments.
55
-- Error: tests/init/neg/cycle-structure.scala:9:14 --------------------------------------------------------------------
66
9 | val x = A(this) // error
77
| ^^^^
8-
| Promote the value under initialization to fully-initialized. May only use initialized value as arguments.
8+
| Cannot prove that the value is fully initialized. May only use initialized value as arguments.

tests/init/neg/default-this.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Error: tests/init/neg/default-this.scala:9:8 ------------------------------------------------------------------------
22
9 | compare() // error
33
| ^^^^^^^
4-
|Promote the value under initialization to fully-initialized. May only use initialized value as arguments. Calling trace:
5-
| -> val result = updateThenCompare(5) [ default-this.scala:11 ]
4+
| Cannot prove that the value is fully initialized. May only use initialized value as arguments. Calling trace:
5+
| -> val result = updateThenCompare(5) [ default-this.scala:11 ]

tests/init/neg/inherit-non-hot.check

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- Error: tests/init/neg/inherit-non-hot.scala:6:34 --------------------------------------------------------------------
2+
6 | if b == null then b = new B(this) // error
3+
| ^^^^^^^^^^^
4+
| Cannot prove that the value is fully-initialized. May only assign fully initialized value.
5+
| Calling trace:
6+
| -> val c = new C [ inherit-non-hot.scala:19 ]
7+
| -> class C extends A { [ inherit-non-hot.scala:15 ]
8+
| -> val bAgain = toB.getBAgain [ inherit-non-hot.scala:16 ]
9+
|
10+
| The unsafe promotion may cause the following problem:
11+
| Call method Foo.B.this.aCopy.toB on a value with an unknown initialization. Calling trace:
12+
| -> val c = new C [ inherit-non-hot.scala:19 ]
13+
| -> class C extends A { [ inherit-non-hot.scala:15 ]
14+
| -> val bAgain = toB.getBAgain [ inherit-non-hot.scala:16 ]
15+
| -> if b == null then b = new B(this) // error [ inherit-non-hot.scala:6 ]
16+
| -> def getBAgain: B = aCopy.toB [ inherit-non-hot.scala:12 ]

tests/init/neg/inherit-non-hot.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// This is a minimized test for the warning in Names.scala:174
2+
object Foo {
3+
abstract class A {
4+
var b: B = null
5+
def toB: B =
6+
if b == null then b = new B(this) // error
7+
b
8+
}
9+
10+
class B(a: A) {
11+
var aCopy: A = a
12+
def getBAgain: B = aCopy.toB
13+
}
14+
15+
class C extends A {
16+
val bAgain = toB.getBAgain
17+
}
18+
19+
val c = new C
20+
assert(c.b == c.bAgain)
21+
}

tests/init/neg/leak-warm.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
-- Error: tests/init/neg/leak-warm.scala:18:26 -------------------------------------------------------------------------
22
18 | val l: List[A] = List(c, d) // error // error
33
| ^
4-
|Promote the value under initialization to fully-initialized. May only use initialized value as method arguments.
4+
| Cannot prove that the value is fully initialized. May only use initialized value as method arguments.
55
-- Error: tests/init/neg/leak-warm.scala:18:29 -------------------------------------------------------------------------
66
18 | val l: List[A] = List(c, d) // error // error
77
| ^
8-
|Promote the value under initialization to fully-initialized. May only use initialized value as method arguments.
8+
| Cannot prove that the value is fully initialized. May only use initialized value as method arguments.

tests/init/neg/local-warm4.check

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
-- Error: tests/init/neg/local-warm4.scala:18:20 -----------------------------------------------------------------------
22
18 | a = newA // error
33
| ^^^^
4-
|Promote the value under initialization to fully-initialized. May only assign fully initialized value. Calling trace:
5-
| -> val a = new A(5) [ local-warm4.scala:26 ]
6-
| -> class A(x: Int) extends Foo(x) { [ local-warm4.scala:6 ]
7-
| -> val b = new B(y) [ local-warm4.scala:10 ]
8-
| -> 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 ]
4+
| Cannot prove that the value is fully initialized. May only assign fully initialized value. Calling trace:
5+
| -> val a = new A(5) [ local-warm4.scala:26 ]
6+
| -> class A(x: Int) extends Foo(x) { [ local-warm4.scala:6 ]
7+
| -> val b = new B(y) [ local-warm4.scala:10 ]
8+
| -> 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 ]

tests/init/neg/local-warm4.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,3 @@ object localWarm {
2525
}
2626
val a = new A(5)
2727
}
28-
29-
30-
31-

tests/init/neg/promotion-loop.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/init/neg/promotion-loop.scala:16:10 --------------------------------------------------------------------
22
16 | println(b) // error
33
| ^
4-
| Cannot prove that the value is fully-initialized. May only use initialized value as arguments.
4+
| Cannot prove that the value is fully-initialized. May only use initialized value as arguments.
55
|
6-
| The unsafe promotion may cause the following problem:
7-
| Promote the value under initialization to fully-initialized. May only use initialized value as arguments.
6+
| The unsafe promotion may cause the following problem:
7+
| Cannot prove that the value is fully initialized. May only use initialized value as arguments.

tests/init/neg/secondary-ctor2.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ class A(b: B, x: Int) {
66
}
77
Inner().foo()
88

9-
val f = () => new A(b, 3) // error: Cannot promote
10-
f() // ok
9+
val f = () => new A(b, 3)
10+
f()
1111
}
1212
}
1313

tests/init/neg/Desugar.scala renamed to tests/init/pos/Desugar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ case class C[-T >: Int] (lhs: Int, rhs: Tree[T]) extends A {
99
}
1010

1111
object DesugarError {
12-
val f: PartialFunction[A, Int] = {case C(_, rhs) => rhs.x} // error
12+
val f: PartialFunction[A, Int] = {case C(_, rhs) => rhs.x}
1313
}
1414

1515

tests/init/neg/InteractiveDriver.scala renamed to tests/init/pos/InteractiveDriver.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ object InteractiveDriver {
1919
case _ => new C[Int]
2020
}
2121
val l: Seq[Any] = Seq(1, 2, new C[Double], new D[Int])
22-
val l2: Seq[C[?]] = l.collect{ case x: InteractiveDriver[?] => h(x) } // error
22+
val l2: Seq[C[?]] = l.collect{ case x: InteractiveDriver[?] => h(x) }
2323
}

0 commit comments

Comments
 (0)