Skip to content

Commit d1392f3

Browse files
committed
Give run/string-switch-pos an alternative pattern case
... for the next commit.
1 parent fd69ef8 commit d1392f3

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

test/files/run/string-switch-pos.check

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[[syntax trees at end of patmat]] // newSource1.scala
2-
[0:187]package [0:0]<empty> {
3-
[0:187]class Switch extends [13:187][187]scala.AnyRef {
4-
[187]def <init>(): [13]Switch = [187]{
5-
[187][187][187]Switch.super.<init>();
2+
[0:216]package [0:0]<empty> {
3+
[0:216]class Switch extends [13:216][216]scala.AnyRef {
4+
[216]def <init>(): [13]Switch = [216]{
5+
[216][216][216]Switch.super.<init>();
66
[13]()
77
};
8-
[17:185]def switch([28:37]s: [31:37]<type: [31:37]scala.Predef.String>, [39:52]cond: [45:52]<type: [45:52]scala.Boolean>): [21]Int = [56:57]{
8+
[17:214]def switch([28:37]s: [31:37]<type: [31:37]scala.Predef.String>, [39:52]cond: [45:52]<type: [45:52]scala.Boolean>): [21]Int = [56:57]{
99
[56:57]case <synthetic> val x1: [56]String = [56:57]s;
1010
[56:57][56:57]x1 match {
1111
[56:57]case [75:81]"AaAa" => [93:94]1
@@ -14,22 +14,27 @@
1414
[151:152]3
1515
else
1616
[180:181]4
17+
[56:57]case [56:57]([191:197]"CcCc"| [200:205]"Cc2") => [209:210]5
1718
[56:57]case [56:57]_ => [56:57]throw [56:57][56:57][56:57]new [56:57]MatchError([56:57]x1)
1819
}
1920
}
2021
}
2122
}
2223

2324
[[syntax trees at end of cleanup]] // newSource1.scala
24-
[0:187]package [0:0]<empty> {
25-
[0:187]class Switch extends [13:187][13:187]Object {
26-
[17:185]def switch([28:37]s: [31:37]<type: [31:37]scala.Predef.String>, [39:52]cond: [45:52]<type: [45:52]scala.Boolean>): [21]Int = [56:57]{
25+
[0:216]package [0:0]<empty> {
26+
[0:216]class Switch extends [13:216][13:216]Object {
27+
[17:214]def switch([28:37]s: [31:37]<type: [31:37]scala.Predef.String>, [39:52]cond: [45:52]<type: [45:52]scala.Boolean>): [21]Int = [56:57]{
2728
[56:57]case <synthetic> val x1: [56]String = [56:57]s;
2829
[56:57]{
2930
[56:139][56:57]if ([56][56]x1.eq([56]null))
3031
[56]0
3132
else
3233
[56][56]x1.hashCode() match {
34+
[56:57]case [56]67506 => [56:57]if ([56][56][56]"Cc2".equals([56]x1))
35+
[56][56]case4()
36+
else
37+
[56][56]matchEnd2()
3338
[75:81]case [56]2031744 => [75:81]if ([75][75][75]"AaAa".equals([75]x1))
3439
[75][75]case1()
3540
else
@@ -38,6 +43,10 @@
3843
[133][133]case3()
3944
else
4045
[56][56]matchEnd2()
46+
[56:57]case [56]2093312 => [56:57]if ([56][56][56]"CcCc".equals([56]x1))
47+
[56][56]case4()
48+
else
49+
[56][56]matchEnd2()
4150
[104:110]case [56]3003444 => [104:110]if ([104][104][104]"asdf".equals([104]x1))
4251
[104][104]case2()
4352
else
@@ -56,6 +65,9 @@
5665
else
5766
[180:181]4)
5867
};
68+
[56]case4(){
69+
[56][56]matchEnd1([209:210]5)
70+
};
5971
[56]matchEnd2(){
6072
[56][56]matchEnd1([56:57]throw [56:57][56:57][56:57]new [56:57]MatchError([56:57]x1))
6173
};
@@ -64,8 +76,8 @@
6476
}
6577
}
6678
};
67-
[187]def <init>(): [13]Switch = [187]{
68-
[187][187][187]Switch.super.<init>();
79+
[216]def <init>(): [13]Switch = [216]{
80+
[216][216][216]Switch.super.<init>();
6981
[13]()
7082
}
7183
}

test/files/run/string-switch-pos.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ object Test extends DirectTest {
1010
| case "asdf" => 2
1111
| case "BbBb" if cond => 3
1212
| case "BbBb" => 4
13+
| case "CcCc" | "Cc2" => 5
1314
| }
1415
|}
1516
""".stripMargin.trim
1617

1718
override def show(): Unit = Console.withErr(Console.out) { super.compile() }
18-
}
19+
}

0 commit comments

Comments
 (0)