From ee365cccaf740d5ec353718556b010137f4cdd4d Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Mon, 16 May 2016 23:28:16 -0700 Subject: 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. --- src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/compiler') 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 -- cgit v1.2.3