summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala4
-rw-r--r--test/files/run/t4625b.check1
-rw-r--r--test/files/run/t4625b.scala7
-rw-r--r--test/files/run/t4625b.script8
4 files changed, 19 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 358ccb5dc3..1ece580b96 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -384,7 +384,7 @@ self =>
case _ => false
}
def isApp(t: Tree) = t match {
- case Template(ps, _, _) => ps.exists(cond(_) { case Ident(tpnme.App) => true })
+ case Template(parents, _, _) => parents.exists(cond(_) { case Ident(tpnme.App) => true })
case _ => false
}
/* For now we require there only be one top level object. */
@@ -402,6 +402,8 @@ self =>
*/
if (name == mainModuleName) md
else treeCopy.ModuleDef(md, mods, mainModuleName, template)
+ case md @ ModuleDef(_, _, _) => md
+ case cd @ ClassDef(_, _, _, _) => cd
case _ =>
/* If we see anything but the above, fail. */
return None
diff --git a/test/files/run/t4625b.check b/test/files/run/t4625b.check
new file mode 100644
index 0000000000..e79539a5c4
--- /dev/null
+++ b/test/files/run/t4625b.check
@@ -0,0 +1 @@
+Misc top-level detritus
diff --git a/test/files/run/t4625b.scala b/test/files/run/t4625b.scala
new file mode 100644
index 0000000000..44f6225220
--- /dev/null
+++ b/test/files/run/t4625b.scala
@@ -0,0 +1,7 @@
+
+import scala.tools.partest.ScriptTest
+
+object Test extends ScriptTest {
+ // must be called Main to get probing treatment in parser
+ override def testmain = "Main"
+}
diff --git a/test/files/run/t4625b.script b/test/files/run/t4625b.script
new file mode 100644
index 0000000000..f21a553dd1
--- /dev/null
+++ b/test/files/run/t4625b.script
@@ -0,0 +1,8 @@
+
+trait X { def x = "Misc top-level detritus" }
+
+object Bumpkus
+
+object Main extends X with App {
+ println(x)
+}