summaryrefslogtreecommitdiff
path: root/test/files/run/t8100.scala
diff options
context:
space:
mode:
authorErik Osheim <d_m@plastic-idolatry.com>2013-12-24 15:52:17 -0500
committerErik Osheim <d_m@plastic-idolatry.com>2013-12-24 15:58:50 -0500
commit2477bbd9d64df3dbfac063e1fc71115daf0f3ea7 (patch)
treeb0dc9f7b266fd4746ddc4eb8393bcf55f7562cb7 /test/files/run/t8100.scala
parent9f0594c57716ed551918e15be6da843982e8ba12 (diff)
downloadscala-2477bbd9d64df3dbfac063e1fc71115daf0f3ea7.tar.gz
scala-2477bbd9d64df3dbfac063e1fc71115daf0f3ea7.tar.bz2
scala-2477bbd9d64df3dbfac063e1fc71115daf0f3ea7.zip
SI-8100 - prevent possible SOE during Stream#flatten.
This commit changes stream flatten to avoid allocating a stack frame for every stream item. Previously, flattening a stream whose elements are mostly empty would result in a StackOverflowException. This commit also adds a test demonstrating the problem.
Diffstat (limited to 'test/files/run/t8100.scala')
-rw-r--r--test/files/run/t8100.scala8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/files/run/t8100.scala b/test/files/run/t8100.scala
new file mode 100644
index 0000000000..b9d0fe5003
--- /dev/null
+++ b/test/files/run/t8100.scala
@@ -0,0 +1,8 @@
+object Test {
+ import scala.util.Try
+
+ def main(args: Array[String]): Unit = {
+ def stream = Stream.from(0).take(100000).map(n => None)
+ println(Try(stream.flatten.length))
+ }
+}