summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2012-07-20 01:49:36 -0700
committerAdriaan Moors <adriaan.moors@epfl.ch>2012-07-20 01:49:36 -0700
commit314133f98118d6d2f9f515fcc5aa7a2e7e9a4559 (patch)
tree12f743d8432e107af1055d0670f5bc067ce3a215 /test/files
parenta8bd1e25b9fe32a8eff2f51ee3bfa527440beb84 (diff)
parentc2aa17a72afa3dbc3a6c967b2fc8ade0a5a34637 (diff)
downloadscala-314133f98118d6d2f9f515fcc5aa7a2e7e9a4559.tar.gz
scala-314133f98118d6d2f9f515fcc5aa7a2e7e9a4559.tar.bz2
scala-314133f98118d6d2f9f515fcc5aa7a2e7e9a4559.zip
Merge pull request #937 from adriaanm/ticket-5739
SI-5739 store sub-patterns in local vals
Diffstat (limited to 'test/files')
-rw-r--r--test/files/neg/t4425.check5
-rw-r--r--test/files/run/inline-ex-handlers.check80
-rw-r--r--test/files/run/t5158.check1
-rw-r--r--test/files/run/t5158.scala17
-rw-r--r--test/files/run/t6070.check1
-rw-r--r--test/files/run/t6070.scala36
6 files changed, 98 insertions, 42 deletions
diff --git a/test/files/neg/t4425.check b/test/files/neg/t4425.check
index 0f2fe6f2d1..a6a1a1fad4 100644
--- a/test/files/neg/t4425.check
+++ b/test/files/neg/t4425.check
@@ -1,4 +1,5 @@
-t4425.scala:3: error: isInstanceOf cannot test if value types are references.
+t4425.scala:3: error: error during expansion of this match (this is a scalac bug).
+The underlying error was: value _1 is not a member of object Foo.X
42 match { case _ X _ => () }
- ^
+ ^
one error found
diff --git a/test/files/run/inline-ex-handlers.check b/test/files/run/inline-ex-handlers.check
index 7d96c447b0..25e1b2a4dd 100644
--- a/test/files/run/inline-ex-handlers.check
+++ b/test/files/run/inline-ex-handlers.check
@@ -34,11 +34,11 @@
< 101 JUMP 4
<
< 4:
-512c517
+515c520
< blocks: [1,2,3,4,6,7,8,9,10]
---
> blocks: [1,2,3,4,6,7,8,9,10,11,12,13]
-541c546,551
+544c549,554
< 306 THROW(MyException)
---
> ? JUMP 11
@@ -47,7 +47,7 @@
> ? LOAD_LOCAL(variable monitor4)
> 305 MONITOR_EXIT
> ? JUMP 12
-547c557,563
+550c560,566
< ? THROW(Throwable)
---
> ? JUMP 12
@@ -57,7 +57,7 @@
> 304 MONITOR_EXIT
> ? STORE_LOCAL(value t)
> ? JUMP 13
-553c569,582
+556c572,585
< ? THROW(Throwable)
---
> ? STORE_LOCAL(value t)
@@ -74,19 +74,19 @@
> 310 CALL_PRIMITIVE(EndConcat)
> 310 CALL_METHOD scala.Predef.println (dynamic)
> 310 JUMP 2
-577c606
+580c609
< catch (Throwable) in ArrayBuffer(7, 8, 9, 10) starting at: 6
---
> catch (Throwable) in ArrayBuffer(7, 8, 9, 10, 11) starting at: 6
-580c609
+583c612
< catch (Throwable) in ArrayBuffer(4, 6, 7, 8, 9, 10) starting at: 3
---
> catch (Throwable) in ArrayBuffer(4, 6, 7, 8, 9, 10, 11, 12) starting at: 3
-612c641
+615c644
< blocks: [1,2,3,4,5,6,7,9,10]
---
> blocks: [1,2,3,4,5,6,7,9,10,11,12]
-636c665,671
+639c668,674
< 78 THROW(IllegalArgumentException)
---
> ? STORE_LOCAL(value e)
@@ -96,7 +96,7 @@
> 81 LOAD_LOCAL(value e)
> ? STORE_LOCAL(variable exc1)
> ? JUMP 12
-665c700,714
+668c703,717
< 81 THROW(Exception)
---
> ? STORE_LOCAL(variable exc1)
@@ -114,15 +114,15 @@
> 84 STORE_LOCAL(variable result)
> 84 LOAD_LOCAL(variable exc1)
> 84 THROW(Throwable)
-687c736
+690c739
< catch (<none>) in ArrayBuffer(4, 6, 7, 9) starting at: 3
---
> catch (<none>) in ArrayBuffer(4, 6, 7, 9, 11) starting at: 3
-713c762
+716c765
< blocks: [1,2,3,4,5,6,9,12,14,17,18,19,22,25,27,28,30,31]
---
> blocks: [1,2,3,4,5,6,9,12,14,17,18,19,22,25,27,28,30,31,32,33,34]
-737c786,793
+740c789,796
< 172 THROW(MyException)
---
> ? STORE_LOCAL(value ex6)
@@ -133,12 +133,12 @@
> 170 STORE_LOCAL(value x4)
> 170 SCOPE_ENTER value x4
> 170 JUMP 18
-793c849,850
+798c854,855
< 177 THROW(MyException)
---
> ? STORE_LOCAL(value ex6)
> ? JUMP 33
-797c854,861
+802c859,866
< 170 THROW(Throwable)
---
> ? STORE_LOCAL(value ex6)
@@ -149,17 +149,17 @@
> 169 STORE_LOCAL(value x4)
> 169 SCOPE_ENTER value x4
> 169 JUMP 5
-830c894,895
+837c901,902
< 182 THROW(MyException)
---
> ? STORE_LOCAL(variable exc2)
> ? JUMP 34
-834c899,900
+841c906,907
< 169 THROW(Throwable)
---
> ? STORE_LOCAL(variable exc2)
> ? JUMP 34
-835a902,914
+842a909,921
> 34:
> 184 LOAD_MODULE object Predef
> 184 CONSTANT("finally")
@@ -173,19 +173,19 @@
> 185 LOAD_LOCAL(variable exc2)
> 185 THROW(Throwable)
>
-856c935
+863c942
< catch (Throwable) in ArrayBuffer(17, 18, 19, 22, 25, 27, 28, 30) starting at: 4
---
> catch (Throwable) in ArrayBuffer(17, 18, 19, 22, 25, 27, 28, 30, 32) starting at: 4
-859c938
+866c945
< catch (<none>) in ArrayBuffer(4, 5, 6, 9, 12, 17, 18, 19, 22, 25, 27, 28, 30) starting at: 3
---
> catch (<none>) in ArrayBuffer(4, 5, 6, 9, 12, 17, 18, 19, 22, 25, 27, 28, 30, 32, 33) starting at: 3
-885c964
+892c971
< blocks: [1,2,3,6,7,8,11,14,16,17,19]
---
> blocks: [1,2,3,6,7,8,11,14,16,17,19,20]
-909c988,995
+916c995,1002
< 124 THROW(MyException)
---
> ? STORE_LOCAL(value ex6)
@@ -196,15 +196,15 @@
> 122 STORE_LOCAL(value x4)
> 122 SCOPE_ENTER value x4
> 122 JUMP 7
-969c1055
+979c1065
< catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 14, 16, 17, 19) starting at: 3
---
> catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 14, 16, 17, 19, 20) starting at: 3
-995c1081
+1005c1091
< blocks: [1,2,3,4,5,8,11,15,16,17,19]
---
> blocks: [1,2,3,5,8,11,15,16,17,19,20]
-1019c1105,1114
+1029c1115,1124
< 148 THROW(MyException)
---
> ? STORE_LOCAL(value ex6)
@@ -217,15 +217,15 @@
> 154 LOAD_LOCAL(value x4)
> 154 IS_INSTANCE REF(class MyException)
> 154 CZJUMP (BOOL)NE ? 5 : 11
-1040,1042d1134
+1050,1052d1144
< 145 JUMP 4
<
< 4:
-1275c1367
+1288c1380
< blocks: [1,2,3,4,5,7]
---
> blocks: [1,2,3,4,5,7,8]
-1299c1391,1398
+1312c1404,1411
< 38 THROW(IllegalArgumentException)
---
> ? STORE_LOCAL(value e)
@@ -236,16 +236,16 @@
> 42 CONSTANT("IllegalArgumentException")
> 42 CALL_METHOD scala.Predef.println (dynamic)
> 42 JUMP 2
-1348c1447
+1361c1460
< blocks: [1,2,3,4,5,8,11,13,14,16,17,19]
---
> blocks: [1,2,3,5,8,11,13,14,16,17,19,20]
-1372c1471,1472
+1385c1484,1485
< 203 THROW(MyException)
---
> ? STORE_LOCAL(value ex6)
> ? JUMP 20
-1392c1492,1501
+1405c1505,1514
< 209 THROW(MyException)
---
> ? STORE_LOCAL(value ex6)
@@ -258,15 +258,15 @@
> 212 LOAD_LOCAL(value x4)
> 212 IS_INSTANCE REF(class MyException)
> 212 CZJUMP (BOOL)NE ? 5 : 11
-1405,1407d1513
+1418,1420d1526
< 200 JUMP 4
<
< 4:
-1467c1573
+1483c1589
< blocks: [1,2,3,4,5,7]
---
> blocks: [1,2,3,4,5,7,8]
-1491c1597,1604
+1507c1613,1620
< 58 THROW(IllegalArgumentException)
---
> ? STORE_LOCAL(value e)
@@ -277,11 +277,11 @@
> 62 CONSTANT("RuntimeException")
> 62 CALL_METHOD scala.Predef.println (dynamic)
> 62 JUMP 2
-1540c1653
+1556c1669
< blocks: [1,2,3,4]
---
> blocks: [1,2,3,4,5]
-1560c1673,1678
+1576c1689,1694
< 229 THROW(MyException)
---
> ? JUMP 5
@@ -290,19 +290,19 @@
> ? LOAD_LOCAL(variable monitor1)
> 228 MONITOR_EXIT
> 228 THROW(Throwable)
-1566c1684
+1582c1700
< ? THROW(Throwable)
---
> 228 THROW(Throwable)
-1594c1712
+1610c1728
< locals: value args, variable result, variable monitor2, variable monitorResult1
---
> locals: value exception$1, value args, variable result, variable monitor2, variable monitorResult1
-1596c1714
+1612c1730
< blocks: [1,2,3,4]
---
> blocks: [1,2,3,4,5]
-1619c1737,1745
+1635c1753,1761
< 245 THROW(MyException)
---
> ? STORE_LOCAL(value exception$1)
@@ -314,7 +314,7 @@
> ? LOAD_LOCAL(variable monitor2)
> 244 MONITOR_EXIT
> 244 THROW(Throwable)
-1625c1751
+1641c1767
< ? THROW(Throwable)
---
> 244 THROW(Throwable)
diff --git a/test/files/run/t5158.check b/test/files/run/t5158.check
new file mode 100644
index 0000000000..573541ac97
--- /dev/null
+++ b/test/files/run/t5158.check
@@ -0,0 +1 @@
+0
diff --git a/test/files/run/t5158.scala b/test/files/run/t5158.scala
new file mode 100644
index 0000000000..3028ffa9e0
--- /dev/null
+++ b/test/files/run/t5158.scala
@@ -0,0 +1,17 @@
+case class B(var x: Int) {
+ def succ() {
+ x = x + 1
+ }
+}
+
+object Test {
+ def main(args: Array[String]) {
+ val b = B(0)
+ b match {
+ case B(x) =>
+ //println(x)
+ b.succ()
+ println(x)
+ }
+ }
+} \ No newline at end of file
diff --git a/test/files/run/t6070.check b/test/files/run/t6070.check
new file mode 100644
index 0000000000..00750edc07
--- /dev/null
+++ b/test/files/run/t6070.check
@@ -0,0 +1 @@
+3
diff --git a/test/files/run/t6070.scala b/test/files/run/t6070.scala
new file mode 100644
index 0000000000..b6af48ef21
--- /dev/null
+++ b/test/files/run/t6070.scala
@@ -0,0 +1,36 @@
+abstract class Bomb {
+ type T
+ val x: T
+
+ def size(that: T): Int
+}
+
+class StringBomb extends Bomb {
+ type T = String
+ val x = "abc"
+ def size(that: String): Int = that.length
+}
+
+class IntBomb extends Bomb {
+ type T = Int
+ val x = 10
+
+ def size(that: Int) = x + that
+}
+
+case class Mean(var bomb: Bomb)
+
+object Test extends App {
+ def foo(x: Mean) = x match {
+ case Mean(b) =>
+ // BUG: b is assumed to be a stable identifier, but it can actually be mutated
+ println(b.size({ mutate(); b.x }))
+ }
+
+ def mutate() {
+ m.bomb = new IntBomb
+ }
+
+ val m = Mean(new StringBomb)
+ foo(m) // should print 3
+} \ No newline at end of file