diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-12-19 08:17:43 -0800 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-12-19 08:17:43 -0800 |
commit | fa20a1c9c479ceff93075fca40be6ee89a97e4c8 (patch) | |
tree | 895b5359fbb2b4b4784502501011ec8f1dfcbaf7 /test/files | |
parent | fc8bfb4b7564151eecb721c831f3f7d0655f2b1e (diff) | |
parent | 3b8b24a48b1ebc81eb6154c4f8c8c8d82ac3de48 (diff) | |
download | scala-fa20a1c9c479ceff93075fca40be6ee89a97e4c8.tar.gz scala-fa20a1c9c479ceff93075fca40be6ee89a97e4c8.tar.bz2 scala-fa20a1c9c479ceff93075fca40be6ee89a97e4c8.zip |
Merge pull request #3234 from retronym/ticket/5508-3
Fix crasher with private[this] in nested traits
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/neg/t6231.check | 6 | ||||
-rw-r--r-- | test/files/neg/t6231.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t5508-min-okay.scala | 6 | ||||
-rw-r--r-- | test/files/pos/t5508-min-okay2.scala | 4 | ||||
-rw-r--r-- | test/files/pos/t5508-min.scala | 6 | ||||
-rw-r--r-- | test/files/pos/t5508.scala | 83 | ||||
-rw-r--r-- | test/files/pos/t6231.scala (renamed from test/files/neg/t6231.scala) | 0 | ||||
-rw-r--r-- | test/files/pos/t6231b.scala | 8 |
8 files changed, 107 insertions, 7 deletions
diff --git a/test/files/neg/t6231.check b/test/files/neg/t6231.check deleted file mode 100644 index 6e107c97c7..0000000000 --- a/test/files/neg/t6231.check +++ /dev/null @@ -1,6 +0,0 @@ -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 <$anon: Function0>. You can manually assign it to a val inside the trait, -and refer to that val in <$anon: Function0>. For more details, see SI-6231. - def qux = { () => ev } - ^ -one error found diff --git a/test/files/neg/t6231.flags b/test/files/neg/t6231.flags deleted file mode 100644 index ac96850b69..0000000000 --- a/test/files/neg/t6231.flags +++ /dev/null @@ -1 +0,0 @@ --Ydelambdafy:inline
\ No newline at end of file diff --git a/test/files/pos/t5508-min-okay.scala b/test/files/pos/t5508-min-okay.scala new file mode 100644 index 0000000000..3a38b9c5ea --- /dev/null +++ b/test/files/pos/t5508-min-okay.scala @@ -0,0 +1,6 @@ +object Test { + trait NestedTrait { // must be nested and a trait + private val _st : Int = 0 // crashes if changed to private[this] + val escape = { () => _st } + } +} diff --git a/test/files/pos/t5508-min-okay2.scala b/test/files/pos/t5508-min-okay2.scala new file mode 100644 index 0000000000..935f28609c --- /dev/null +++ b/test/files/pos/t5508-min-okay2.scala @@ -0,0 +1,4 @@ +trait TopTrait { // must be nested and a trait + private[this] val _st : Int = 0 // crashes if TopTrait is not top level + val escape = { () => _st } +} diff --git a/test/files/pos/t5508-min.scala b/test/files/pos/t5508-min.scala new file mode 100644 index 0000000000..f59d2bd6ad --- /dev/null +++ b/test/files/pos/t5508-min.scala @@ -0,0 +1,6 @@ +object Test { + trait NestedTrait { // must be nested and a trait + private[this] val _st : Int = 0 // must be private[this] + val escape = { () => _st } + } +} diff --git a/test/files/pos/t5508.scala b/test/files/pos/t5508.scala new file mode 100644 index 0000000000..2b49758045 --- /dev/null +++ b/test/files/pos/t5508.scala @@ -0,0 +1,83 @@ +package TestTestters + +trait Test1 { + private[this] var _st : Int = 0 + def close : PartialFunction[Any,Any] = { + case x : Int => + _st = identity(_st) + } +} + +object Base1 { + trait Test2 { + private[this] var _st : Int = 0 + def close : PartialFunction[Any,Any] = { + case x : Int => + _st = identity(_st) + } + } +} + +class Test3 { + private[this] var _st : Int = 0 + def close : PartialFunction[Any,Any] = { + case x : Int => + _st = 1 + } +} + +object Base2 { + class Test4 { + private[this] var _st : Int = 0 + def close : PartialFunction[Any,Any] = { + case x : Int => + _st = 1 + } + } +} + +class Base3 { + trait Test5 { + private[this] var _st : Int = 0 + def close : PartialFunction[Any,Any] = { + case x : Int => + _st = 1 + } + } +} + +object Base4 { + trait Test6 { + private[this] var _st : Int = 0 + def close : PartialFunction[Any,Any] = { + case x : Int => () + } + } +} + +object Base5 { + trait Test7 { + private[this] var _st : Int = 0 + def close = () => { + _st = 1 + } + } +} + +object Base6 { + class Test8 { + private[this] var _st : Int = 0 + def close = () => { + _st = 1 + } + } +} + +object Base7 { + trait Test9 { + var st : Int = 0 + def close = () => { + st = 1 + } + } +} diff --git a/test/files/neg/t6231.scala b/test/files/pos/t6231.scala index 1e5b4e0e1a..1e5b4e0e1a 100644 --- a/test/files/neg/t6231.scala +++ b/test/files/pos/t6231.scala diff --git a/test/files/pos/t6231b.scala b/test/files/pos/t6231b.scala new file mode 100644 index 0000000000..b4ddfe785b --- /dev/null +++ b/test/files/pos/t6231b.scala @@ -0,0 +1,8 @@ +class Test { + def f1(t: String) = { + trait T { + def xs = Nil map (_ => t) + } + () + } +} |