summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2016-05-16 22:57:51 -0700
committerSom Snytt <som.snytt@gmail.com>2016-05-16 22:57:51 -0700
commit5bcefbe1889a1b8e1f9bac04090428eaaa7b2fd3 (patch)
treed95c60913736c666c9616f25e8fc7e31ef357055 /src
parent73ca44be579e5100706d174f18025fc4487e9cb9 (diff)
downloadscala-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')
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala5
-rw-r--r--src/reflect/scala/reflect/internal/StdNames.scala1
2 files changed, 5 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. */
diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala
index 52558d9395..a0688e129c 100644
--- a/src/reflect/scala/reflect/internal/StdNames.scala
+++ b/src/reflect/scala/reflect/internal/StdNames.scala
@@ -240,6 +240,7 @@ trait StdNames {
final val Any: NameType = "Any"
final val AnyVal: NameType = "AnyVal"
+ final val App: NameType = "App"
final val FlagSet: NameType = "FlagSet"
final val Mirror: NameType = "Mirror"
final val Modifiers: NameType = "Modifiers"