summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-01-25 09:11:04 -0800
committerPaul Phillips <paulp@improving.org>2013-01-25 09:11:04 -0800
commit3753efc060af39d9247273cdc8da74ce57f627c5 (patch)
treed45a68bb01cc8eb1ba8142d76fde9f6361dc6fb4 /test
parent0e6015d46df35a57c5acaf4fea2b0555ddd9b18e (diff)
parentf6168b8a4d661985b0fb4d6d3cbba256bfc69607 (diff)
downloadscala-3753efc060af39d9247273cdc8da74ce57f627c5.tar.gz
scala-3753efc060af39d9247273cdc8da74ce57f627c5.tar.bz2
scala-3753efc060af39d9247273cdc8da74ce57f627c5.zip
Merge pull request #1946 from retronym/ticket/6231
SI-6231 Report unsupported free var capture by a trait.
Diffstat (limited to 'test')
-rw-r--r--test/files/neg/t6231.check6
-rw-r--r--test/files/neg/t6231.scala15
2 files changed, 21 insertions, 0 deletions
diff --git a/test/files/neg/t6231.check b/test/files/neg/t6231.check
new file mode 100644
index 0000000000..b27961d393
--- /dev/null
+++ b/test/files/neg/t6231.check
@@ -0,0 +1,6 @@
+t6231.scala:4: error: Implementation restriction: local trait Bug$X$1 is unable to automatically capture the
+free variable value ev$1 on behalf of anonymous class anonfun$qux$1. You can manually assign it to a val inside the trait,
+and refer that that val in anonymous class anonfun$qux$1. For more details, see SI-6231.
+ def qux = { () => ev }
+ ^
+one error found
diff --git a/test/files/neg/t6231.scala b/test/files/neg/t6231.scala
new file mode 100644
index 0000000000..1e5b4e0e1a
--- /dev/null
+++ b/test/files/neg/t6231.scala
@@ -0,0 +1,15 @@
+object Bug {
+ def bar(ev: Any) = {
+ trait X {
+ def qux = { () => ev }
+ }
+ new X {}.qux()
+
+ // workaround
+ trait Y {
+ val ev2 = ev // manually capture `ev` so that `ev2` is added to the trait interface.
+ def qux = { () => ev2 }
+ }
+ }
+}
+