summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2013-08-30 07:12:03 -0700
committerSom Snytt <som.snytt@gmail.com>2013-08-30 17:49:36 -0700
commit27d61a2ef6c3059fd56a36fc18886fc53bb354a8 (patch)
treece49efff3e52cc3964273bb9c2c10ec6289132be
parent7a0d983aedd8ad8f3f41a22ffa0ce4b6ab2f1523 (diff)
downloadscala-27d61a2ef6c3059fd56a36fc18886fc53bb354a8.tar.gz
scala-27d61a2ef6c3059fd56a36fc18886fc53bb354a8.tar.bz2
scala-27d61a2ef6c3059fd56a36fc18886fc53bb354a8.zip
SI-4760 Parser handles block-ending import
Don't molest the RBRACE. Updated with additional parse tests suggested by @retronym. "What are you lazy?" Yes, I must be lazy. Can't ScalaCheck or Par-Test generate these tests automatically? That seems like a reasonable expectation.
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala2
-rw-r--r--test/files/pos/t4760.scala34
2 files changed, 35 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 50398824e1..5476afa75e 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -3067,7 +3067,7 @@ self =>
while (!isStatSeqEnd && in.token != CASE) {
if (in.token == IMPORT) {
stats ++= importClause()
- acceptStatSep()
+ acceptStatSepOpt()
}
else if (isExprIntro) {
stats += statement(InBlock)
diff --git a/test/files/pos/t4760.scala b/test/files/pos/t4760.scala
new file mode 100644
index 0000000000..767e3847f4
--- /dev/null
+++ b/test/files/pos/t4760.scala
@@ -0,0 +1,34 @@
+
+class Test {
+ // parses
+ def f1 = {
+ import scala._;
+ }
+ // b.scala:7: error: ';' expected but '}' found.
+ // }
+ // ^
+ // one error found
+ def f2 = {
+ import scala._
+ }
+ def f2b = {
+ import scala.collection.mutable.{ Map => MMap }
+ }
+ def f(): Unit = {
+ locally {
+ import scala.util.Properties.lineSeparator
+ }
+ }
+
+ // parses
+ def f3 = {
+ import scala._
+ 5
+ }
+ locally { (x: Int) =>
+ import scala.util._
+ }
+ 1 match {
+ case 1 => import scala.concurrent._
+ }
+}