diff options
author | Paul Phillips <paulp@improving.org> | 2011-04-30 20:01:00 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-04-30 20:01:00 +0000 |
commit | 793796eee0769926a3162d69dd23c282ca2d8ba4 (patch) | |
tree | 74158caa4474b31e69f20d976fd4966758826832 | |
parent | acc5311c157358c99420ba5a8be4231ffae9fc8e (diff) | |
download | scala-793796eee0769926a3162d69dd23c282ca2d8ba4.tar.gz scala-793796eee0769926a3162d69dd23c282ca2d8ba4.tar.bz2 scala-793796eee0769926a3162d69dd23c282ca2d8ba4.zip |
Don't crash the pickler with erroneous types.
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala | 9 | ||||
-rw-r--r-- | test/files/neg/bug4533.check | 4 | ||||
-rw-r--r-- | test/files/neg/bug4533.scala | 8 |
3 files changed, 21 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index 0940598bd2..862e37ec2b 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -56,6 +56,15 @@ abstract class Pickler extends SubComponent { case _ => } } + // If there are any erroneous types in the tree, then we will crash + // when we pickle it: so let's report an erorr instead. We know next + // to nothing about what happened, but our supposition is a lot better + // than "bad type: <error>" in terms of explanatory power. + for (t <- unit.body ; if t.isErroneous) { + unit.error(t.pos, "erroneous or inaccessible type") + return + } + pickle(unit.body) } } diff --git a/test/files/neg/bug4533.check b/test/files/neg/bug4533.check new file mode 100644 index 0000000000..e1b60aa820 --- /dev/null +++ b/test/files/neg/bug4533.check @@ -0,0 +1,4 @@ +bug4533.scala:6: error: erroneous or inaccessible type + def statusByAlarms(alarms: GenTraversableOnce[FooAlarm]) = println("hello") + ^ +one error found diff --git a/test/files/neg/bug4533.scala b/test/files/neg/bug4533.scala new file mode 100644 index 0000000000..0346b5d1d5 --- /dev/null +++ b/test/files/neg/bug4533.scala @@ -0,0 +1,8 @@ +package demo + +import scala.collection._ + +class CrashDemo { + def statusByAlarms(alarms: GenTraversableOnce[FooAlarm]) = println("hello") +} +class FooAlarm { } |