Skip to content

Commit 8d3a0a7

Browse files
committed
fix bootstrapped tests
1 parent f0d76ca commit 8d3a0a7

9 files changed

+32
-43
lines changed

tests/neg/refutable-pattern-binding-messages.check

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
-- Error: tests/neg/refutable-pattern-binding-messages.scala:5:14 ------------------------------------------------------
2-
5 | val Positive(p) = 5 // error: refutable extractor
3-
| ^^^^^^^^^^^^^^^
4-
| pattern binding uses refutable extractor `Test.Positive`
5-
|
6-
| If this usage is intentional, this can be communicated by adding `: @unchecked` after the expression,
7-
| which may result in a MatchError at runtime.
8-
| This patch can be rewritten automatically under -rewrite -source 3.2-migration.
91
-- Error: tests/neg/refutable-pattern-binding-messages.scala:6:14 ------------------------------------------------------
102
6 | for Positive(i) <- List(1, 2, 3) do () // error: refutable extractor
113
| ^^^^^^^^^^^
@@ -14,14 +6,6 @@
146
| If this usage is intentional, this can be communicated by adding the `case` keyword before the full pattern,
157
| which will result in a filtering for expression (using `withFilter`).
168
| This patch can be rewritten automatically under -rewrite -source 3.2-migration.
17-
-- Error: tests/neg/refutable-pattern-binding-messages.scala:10:20 -----------------------------------------------------
18-
10 | val i :: is = List(1, 2, 3) // error: pattern type more specialized
19-
| ^^^^^^^^^^^^^
20-
| pattern's type ::[Int] is more specialized than the right hand side expression's type List[Int]
21-
|
22-
| If the narrowing is intentional, this can be communicated by adding `: @unchecked` after the expression,
23-
| which may result in a MatchError at runtime.
24-
| This patch can be rewritten automatically under -rewrite -source 3.2-migration.
259
-- Error: tests/neg/refutable-pattern-binding-messages.scala:11:11 -----------------------------------------------------
2610
11 | for ((x: String) <- xs) do () // error: pattern type more specialized
2711
| ^^^^^^
@@ -38,6 +22,22 @@
3822
| If the narrowing is intentional, this can be communicated by adding the `case` keyword before the full pattern,
3923
| which will result in a filtering for expression (using `withFilter`).
4024
| This patch can be rewritten automatically under -rewrite -source 3.2-migration.
25+
-- Error: tests/neg/refutable-pattern-binding-messages.scala:5:14 ------------------------------------------------------
26+
5 | val Positive(p) = 5 // error: refutable extractor
27+
| ^^^^^^^^^^^^^^^
28+
| pattern binding uses refutable extractor `Test.Positive`
29+
|
30+
| If this usage is intentional, this can be communicated by adding `: @unchecked` after the expression,
31+
| which may result in a MatchError at runtime.
32+
| This patch can be rewritten automatically under -rewrite -source 3.2-migration.
33+
-- Error: tests/neg/refutable-pattern-binding-messages.scala:10:20 -----------------------------------------------------
34+
10 | val i :: is = List(1, 2, 3) // error: pattern type more specialized
35+
| ^^^^^^^^^^^^^
36+
| pattern's type ::[Int] is more specialized than the right hand side expression's type List[Int]
37+
|
38+
| If the narrowing is intentional, this can be communicated by adding `: @unchecked` after the expression,
39+
| which may result in a MatchError at runtime.
40+
| This patch can be rewritten automatically under -rewrite -source 3.2-migration.
4141
-- Error: tests/neg/refutable-pattern-binding-messages.scala:16:10 -----------------------------------------------------
4242
16 | val 1 = 2 // error: pattern type does not match
4343
| ^

tests/pos/irrefutable.scala

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
1-
// The test which this should perform but does not
2-
// is that f1 is recognized as irrefutable and f2 is not
3-
// This can be recognized via the generated classes:
4-
//
5-
// A$$anonfun$f1$1.class
6-
// A$$anonfun$f2$1.class
7-
// A$$anonfun$f2$2.class
8-
//
9-
// The extra one in $f2$ is the filter.
10-
//
11-
// !!! Marking with exclamation points so maybe someday
12-
// this test will be finished.
1+
// This tests that f1 is recognized as an irrefutable pattern and f2 is not
132
class A {
143
case class Foo[T](x: T)
154

165
def f1(xs: List[Foo[Int]]) = {
176
for (Foo(x: Int) <- xs) yield x
187
}
198
def f2(xs: List[Foo[Any]]) = {
20-
for (Foo(x: Int) <- xs) yield x
9+
for (case Foo(x: Int) <- xs) yield x
2110
}
2211
}

tests/pos/t6205.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
class A[T]
33
class Test1 {
44
def x(backing: Map[A[_], Any]) =
5-
for( (k: A[kt], v) <- backing)
5+
for(case (k: A[kt], v) <- backing)
66
yield (k: A[kt])
77
}
88

tests/run/ReplacementMatching.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ object Test {
3232

3333
def groupsMatching: Unit = {
3434
val Date = """(\d+)/(\d+)/(\d+)""".r
35-
for (Regex.Groups(a, b, c) <- Date findFirstMatchIn "1/1/2001 marks the start of the millennium. 31/12/2000 doesn't.") {
35+
for (case Regex.Groups(a, b, c) <- Date findFirstMatchIn "1/1/2001 marks the start of the millennium. 31/12/2000 doesn't.") {
3636
assert(a == "1")
3737
assert(b == "1")
3838
assert(c == "2001")
3939
}
40-
for (Regex.Groups(a, b, c) <- (Date findAllIn "1/1/2001 marks the start of the millennium. 31/12/2000 doesn't.").matchData) {
40+
for (case Regex.Groups(a, b, c) <- (Date findAllIn "1/1/2001 marks the start of the millennium. 31/12/2000 doesn't.").matchData) {
4141
assert(a == "1" || a == "31")
4242
assert(b == "1" || b == "12")
4343
assert(c == "2001" || c == "2000")

tests/run/patmat-bind-typed.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
object Test {
2-
def f(xs: List[Any]) = for (key @ (dummy: String) <- xs) yield key
2+
def f(xs: List[Any]) = for (case key @ (dummy: String) <- xs) yield key
33

44
def main(args: Array[String]): Unit = {
55
f("abc" :: Nil) foreach println

tests/run/quoted-sematics-1.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,24 +82,24 @@ def typeChecks(g: Gamma)(level: 0 | 1)(term: Term): Option[Type] =
8282
yield LambdaType(t, res)
8383
case App(fun, arg) => // T-App
8484
for
85-
LambdaType(t1, t2) <- typeChecks(g)(level)(fun)
85+
case LambdaType(t1, t2) <- typeChecks(g)(level)(fun)
8686
`t1` <- typeChecks(g)(level)(arg)
8787
yield t2
8888
case Box(body) if level == 0 => // T-Box
8989
for t <- typeChecks(g)(1)(body) yield BoxType(t)
9090
case Lift(body) if level == 0 => // T-Lift
9191
for NatType <- typeChecks(g)(0)(body) yield BoxType(NatType)
9292
case Splice(body) if level == 1 => // T-Unbox
93-
for BoxType(t) <- typeChecks(g)(0)(body) yield t
93+
for case BoxType(t) <- typeChecks(g)(0)(body) yield t
9494
case Match(scrutinee, pat, thenp, elsep) => // T-Pat
9595
for
96-
BoxType(t1) <- typeChecks(g)(0)(scrutinee)
96+
case BoxType(t1) <- typeChecks(g)(0)(scrutinee)
9797
delta <- typePatChecks(g, t1)(pat)
9898
t <- typeChecks(g ++ delta)(0)(thenp)
9999
`t` <- typeChecks(g)(0)(elsep)
100100
yield t
101101
case Fix(t) if level == 0 =>
102-
for LambdaType(t1, t2) <- typeChecks(g)(0)(t) yield t2 // T-Fix
102+
for case LambdaType(t1, t2) <- typeChecks(g)(0)(t) yield t2 // T-Fix
103103
case _ => None
104104
if res.isEmpty then
105105
println(s"Failed to type $term at level $level with environment $g")

tests/run/t6406-regextract.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ object Test extends App {
2020
val t = "Last modified 2011-07-15"
2121
val p1 = """(\d\d\d\d)-(\d\d)-(\d\d)""".r
2222
val y1: Option[String] = for {
23-
p1(year, month, day) <- p1 findFirstIn t
23+
case p1(year, month, day) <- p1 findFirstIn t
2424
} yield year
2525
val y2: Option[String] = for {
26-
p1(year, month, day) <- p1 findFirstMatchIn t
26+
case p1(year, month, day) <- p1 findFirstMatchIn t
2727
} yield year
2828
println(s"$y1 $y2")
2929

tests/run/t6646.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ object Test {
88
val l = List(PrimaryKey, NoNull, lower)
99

1010
// withFilter must be generated in these
11-
for (option @ NoNull <- l) println("Found " + option)
12-
for (option @ `lower` <- l) println("Found " + option)
13-
for ((`lower`, i) <- l.zipWithIndex) println("Found " + i)
11+
for (case option @ NoNull <- l) println("Found " + option)
12+
for (case option @ `lower` <- l) println("Found " + option)
13+
for (case (`lower`, i) <- l.zipWithIndex) println("Found " + i)
1414

1515
// no withFilter
1616
for (X <- List("A single ident is always a pattern")) println(X)

tests/run/t6968.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
object Test {
22
def main(args: Array[String]): Unit = {
33
val mixedList = List(1,(1,2),4,(3,1),(5,4),6)
4-
val as = for((a,b) <- mixedList) yield a
4+
val as = for(case (a,b) <- mixedList) yield a
55
println(as.mkString(", "))
66
}
77
}

0 commit comments

Comments
 (0)