summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2016-05-16 23:28:16 -0700
committerSom Snytt <som.snytt@gmail.com>2016-05-16 23:28:16 -0700
commitee365cccaf740d5ec353718556b010137f4cdd4d (patch)
tree6446ae35eaeb0c0bf020231fed30ec118b0c37e7 /src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
parent5bcefbe1889a1b8e1f9bac04090428eaaa7b2fd3 (diff)
downloadscala-ee365cccaf740d5ec353718556b010137f4cdd4d.tar.gz
scala-ee365cccaf740d5ec353718556b010137f4cdd4d.tar.bz2
scala-ee365cccaf740d5ec353718556b010137f4cdd4d.zip
SI-4625 Permit arbitrary top-level in script
In an unwrapped script, where a `main` entry point is discovered in a top-level object, retain all top-level classes. Everything winds up in the default package.
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/parser/Parsers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala4
1 files changed, 3 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