Skip to content

Commit 75c9335

Browse files
EnzeXingEnzeXing
EnzeXing
authored and
EnzeXing
committed
updated test cases
1 parent 8eb69ef commit 75c9335

12 files changed

+53
-3
lines changed

tests/init/neg/Desugar.check

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- Error: tests/init/neg/Desugar.scala:12:61 ---------------------------------------------------------------------------
2+
12 | val f: PartialFunction[A, Int] = {case C(_, rhs) => rhs.x} // error
3+
| ^
4+
| Calling the external method constructor $anon may cause initialization errors. Calling trace:
5+
| -> val f: PartialFunction[A, Int] = {case C(_, rhs) => rhs.x} // error [ Desugar.scala:12 ]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- Error: tests/init/neg/InteractiveDriver.scala:22:71 -----------------------------------------------------------------
2+
22 | val l2: Seq[C[?]] = l.collect{ case x: InteractiveDriver[?] => h(x) } // error
3+
| ^
4+
|Calling the external method constructor $anon may cause initialization errors. Calling trace:
5+
| -> val l2: Seq[C[?]] = l.collect{ case x: InteractiveDriver[?] => h(x) } // error [ InteractiveDriver.scala:22 ]

tests/init/neg/InteractiveDriver.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ class D[A <: AnyVal] extends InteractiveDriver[A] {
1515

1616
object InteractiveDriver {
1717
def h(x: InteractiveDriver[?]): C[?] = x match {
18-
case c: C[?] => c // error
18+
case c: C[?] => c
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) }
22+
val l2: Seq[C[?]] = l.collect{ case x: InteractiveDriver[?] => h(x) } // error
2323
}

tests/init/neg/closureLeak.check

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

tests/init/neg/closureLeak.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ class Outer {
99

1010
val l: List[A] = List(new A(5), new A(10))
1111
l.foreach(a => a.addX(this)) // error
12+
val y = 10
1213
}

tests/init/neg/default-this.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
iiii

tests/init/neg/enum.check

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- Error: tests/init/neg/enum.scala:4:8 --------------------------------------------------------------------------------
2+
4 | NoExplanationID // error
3+
| ^
4+
| Promoting the value to fully-initialized is unsafe. May only use initialized value as method arguments
5+
|
6+
| The unsafe promotion may cause the following problem(s):
7+
|
8+
| 1. Calling the external method method name may cause initialization errors. Calling trace:
9+
| -> NoExplanationID // error [ enum.scala:4 ]

tests/init/neg/leak-this-inner.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- Error: tests/init/neg/leak-this-inner.scala:6:14 --------------------------------------------------------------------
2+
6 | val b = B(this) // error
3+
| ^^^^
4+
| Promote the value under initialization to fully-initialized. May only use initialized value as arguments

tests/init/neg/leak-this.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- Error: tests/init/neg/leak-this.scala:2:33 --------------------------------------------------------------------------
2+
2 | val child: Child = new Child(this) // error
3+
| ^^^^
4+
| Promote the value under initialization to fully-initialized. May only use initialized value as arguments

tests/init/neg/leak-warm.check

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- Error: tests/init/neg/leak-warm.scala:18:26 -------------------------------------------------------------------------
2+
18 | val l: List[A] = List(c, d) // error // error
3+
| ^
4+
| Promote the value under initialization to fully-initialized. May only use initialized value as method arguments
5+
-- Error: tests/init/neg/leak-warm.scala:18:29 -------------------------------------------------------------------------
6+
18 | val l: List[A] = List(c, d) // error // error
7+
| ^
8+
| Promote the value under initialization to fully-initialized. May only use initialized value as method arguments

tests/init/neg/leak-warm.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ object leakWarm {
1515
}
1616
val c = new C(1, 2)
1717
val d = new D(3, 4)
18-
val l: List[A] = List(c, d) // error
18+
val l: List[A] = List(c, d) // error // error
1919
val l2 = l.map(_.m())
2020
}

tests/init/neg/local-warm.check

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- Error: tests/init/neg/local-warm.scala:12:12 ------------------------------------------------------------------------
2+
12 | val t = m1() // error
3+
| ^^^^^^^^^^^^
4+
|Promote the value under initialization to fully-initialized. Local definitions may only hold initialized values Calling trace:
5+
| -> val x = g() [ local-warm.scala:15 ]

0 commit comments

Comments
 (0)