Skip to content

Commit bfb10bb

Browse files
committed
Updating tests
1 parent e8e7e15 commit bfb10bb

20 files changed

+131
-48
lines changed

tests/init/crash/i8892.scala

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
trait Reporter:
2+
def report(m: String): Unit
3+
4+
class Dummy extends Reporter:
5+
def report(m: String) = ()
6+
7+
object ABug {
8+
sealed trait Nat {
9+
transparent inline def ++ : Succ[this.type] = Succ(this)
10+
11+
transparent inline def +(inline that: Nat): Nat =
12+
inline this match {
13+
case Zero => that
14+
case Succ(p) => p + that.++
15+
}
16+
}
17+
18+
case object Zero extends Nat
19+
case class Succ[N <: Nat](p: N) extends Nat
20+
21+
transparent inline def toIntg(inline n: Nat): Int =
22+
inline n match {
23+
case Zero => 0
24+
case Succ(p) => toIntg(p) + 1
25+
}
26+
27+
val j31 = toIntg(Zero.++.++.++ + Zero.++)
28+
}

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/access-argument.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class A {
2+
def foo(b: B): A = {
3+
val temp = b
4+
temp.bar(this) // error
5+
}
6+
val x = foo(new B)
7+
}
8+
9+
class B {
10+
def bar(a: A): A = a.x
11+
}

tests/init/neg/closureLeak.check

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
-- Error: tests/init/neg/closureLeak.scala:11:14 -----------------------------------------------------------------------
22
11 | l.foreach(a => a.addX(this)) // error
33
| ^^^^^^^^^^^^^^^^^
4-
| Promoting the value to fully-initialized is unsafe. 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(s):
7-
|
8-
| 1. 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/early-promote5.scala

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

tests/init/neg/enum-desugared.check

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-- Error: tests/init/neg/enum-desugared.scala:17:15 --------------------------------------------------------------------
2+
17 | Array(this.LazyErrorId, this.NoExplanationID) // error // error
3+
| ^^^^^^^^^^^^^^^^
4+
| Cannot prove that the value is fully-initialized. May only use initialized value as method arguments.
5+
|
6+
| The unsafe promotion may cause the following problem:
7+
| Calling the external method method name may cause initialization errors. Calling trace:
8+
| -> Array(this.LazyErrorId, this.NoExplanationID) // error // error [ enum-desugared.scala:17 ]
9+
| -> override def productPrefix: String = this.name() [ enum-desugared.scala:29 ]
10+
-- Error: tests/init/neg/enum-desugared.scala:17:33 --------------------------------------------------------------------
11+
17 | Array(this.LazyErrorId, this.NoExplanationID) // error // error
12+
| ^^^^^^^^^^^^^^^^^^^^
13+
| Cannot prove that the value is fully-initialized. May only use initialized value as method arguments.
14+
|
15+
| The unsafe promotion may cause the following problem:
16+
| Calling the external method method ordinal may cause initialization errors. Calling trace:
17+
| -> Array(this.LazyErrorId, this.NoExplanationID) // error // error [ enum-desugared.scala:17 ]
18+
| -> def errorNumber: Int = this.ordinal() - 2 [ enum-desugared.scala:8 ]

tests/init/neg/enum.check

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

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 & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
-- Error: tests/init/neg/promotion-loop.scala:16:10 --------------------------------------------------------------------
22
16 | println(b) // error
33
| ^
4-
|Promoting the value to fully-initialized is unsafe. 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(s):
7-
|
8-
|1. Promote the value under initialization to fully-initialized. May only use initialized value as arguments. Calling trace:
9-
| -> val outer = test [ promotion-loop.scala:12 ]
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class A(b: B, x: Int) {
77
Inner().foo()
88

99
val f = () => new A(b, 3)
10-
f() // ok
10+
f()
1111
}
1212
}
1313

tests/init/neg/t3273.check

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
-- Error: tests/init/neg/t3273.scala:4:42 ------------------------------------------------------------------------------
22
4 | val num1: LazyList[Int] = 1 #:: num1.map(_ + 1) // error
33
| ^^^^^^^^^^^^^^^
4-
| Promoting the value to fully-initialized is unsafe. 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(s):
7-
|
8-
| 1. Access non-initialized value num1. Calling trace:
6+
| The unsafe promotion may cause the following problem:
7+
| Access non-initialized value num1. Calling trace:
98
| -> val num1: LazyList[Int] = 1 #:: num1.map(_ + 1) // error [ t3273.scala:4 ]
109
-- Error: tests/init/neg/t3273.scala:5:61 ------------------------------------------------------------------------------
1110
5 | val num2: LazyList[Int] = 1 #:: num2.iterator.map(_ + 1).to(LazyList) // error
1211
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13-
| Promoting the value to fully-initialized is unsafe. May only use initialized value as arguments
14-
|
15-
| The unsafe promotion may cause the following problem(s):
12+
| Cannot prove that the value is fully-initialized. May only use initialized value as arguments.
1613
|
17-
| 1. Access non-initialized value num2. Calling trace:
14+
| The unsafe promotion may cause the following problem:
15+
| Access non-initialized value num2. Calling trace:
1816
| -> val num2: LazyList[Int] = 1 #:: num2.iterator.map(_ + 1).to(LazyList) // error [ t3273.scala:5 ]

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

0 commit comments

Comments
 (0)