diff options
author | Som Snytt <som.snytt@gmail.com> | 2016-05-16 22:57:51 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2016-05-16 22:57:51 -0700 |
commit | 5bcefbe1889a1b8e1f9bac04090428eaaa7b2fd3 (patch) | |
tree | d95c60913736c666c9616f25e8fc7e31ef357055 /src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | |
parent | 73ca44be579e5100706d174f18025fc4487e9cb9 (diff) | |
download | scala-5bcefbe1889a1b8e1f9bac04090428eaaa7b2fd3.tar.gz scala-5bcefbe1889a1b8e1f9bac04090428eaaa7b2fd3.tar.bz2 scala-5bcefbe1889a1b8e1f9bac04090428eaaa7b2fd3.zip |
SI-4625 App is a thing
Scripting knows it by name.
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/parser/Parsers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 5 |
1 files changed, 4 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 7af5c505de..358ccb5dc3 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -365,12 +365,15 @@ self => val stmts = parseStats() def mainModuleName = newTermName(settings.script.value) + /* If there is only a single object template in the file and it has a * suitable main method, we will use it rather than building another object * around it. Since objects are loaded lazily the whole script would have * been a no-op, so we're not taking much liberty. */ def searchForMain(): Option[Tree] = { + import PartialFunction.cond + /* Have to be fairly liberal about what constitutes a main method since * nothing has been typed yet - for instance we can't assume the parameter * type will look exactly like "Array[String]" as it could have been renamed @@ -381,7 +384,7 @@ self => case _ => false } def isApp(t: Tree) = t match { - case Template(ps, _, _) => ps.exists { case Ident(x) if x.decoded == "App" => true ; case _ => false } + case Template(ps, _, _) => ps.exists(cond(_) { case Ident(tpnme.App) => true }) case _ => false } /* For now we require there only be one top level object. */ |