From 4dd829b3bb23bcd8cb508c5385f7d865b87f84f8 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 15 Nov 2016 18:17:40 +0100 Subject: [PATCH 1/2] Revert "Add an error message for incorrect sequence wildcard pattern position" This reverts commit 759dcf3f903a75fccfcb9e5039e537f8f08a4858. --- src/dotty/tools/dotc/parsing/Parsers.scala | 4 ++-- .../dotc/reporting/diagnostic/messages.scala | 23 ------------------- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/src/dotty/tools/dotc/parsing/Parsers.scala b/src/dotty/tools/dotc/parsing/Parsers.scala index 717faa8496c5..ef4c970c66e3 100644 --- a/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/src/dotty/tools/dotc/parsing/Parsers.scala @@ -1076,7 +1076,7 @@ object Parsers { val uscoreStart = in.skipToken() if (isIdent(nme.raw.STAR)) { in.nextToken() - if (in.token != RPAREN) syntaxError(SeqWildcardPatternPos(), uscoreStart) + if (in.token != RPAREN) syntaxError("`_*' can be used only for last argument", uscoreStart) Typed(t, atPos(uscoreStart) { Ident(tpnme.WILDCARD_STAR) }) } else { syntaxErrorOrIncomplete(IncorrectRepeatedParameterSyntax()) @@ -1424,7 +1424,7 @@ object Parsers { // `x: _*' is parsed in `ascription' if (isIdent(nme.raw.STAR)) { in.nextToken() - if (in.token != RPAREN) syntaxError(SeqWildcardPatternPos(), wildIndent.pos) + if (in.token != RPAREN) syntaxError("`_*' can be used only for last argument", wildIndent.pos) atPos(wildIndent.pos) { Ident(tpnme.WILDCARD_STAR) } } else wildIndent case LPAREN => diff --git a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index e8f2ab8b7cfd..4ee27c85200a 100644 --- a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -789,27 +789,4 @@ object messages { val msg = "unreachable code" val explanation = "" } - - case class SeqWildcardPatternPos()(implicit ctx: Context) extends Message(31) { - val kind = "Syntax" - val msg = "`_*' can be used only for last argument" - val explanation = { - val code = - """def sumOfTheFirstTwo(list: List[Int]): Int = list match { - | case List(first, second, x:_*) => first + second - | case _ => 0 - |}""" - hl"""|Sequence wildcard pattern is expected at the end of an argument list. - |This pattern matches any remaining elements in a sequence. - |Consider the following example: - | - |$code - | - |Calling: - | - |${"sumOfTheFirstTwo(List(1, 2, 10))"} - | - |would give 3 as a result""" - } - } } From b2c9498f45e0c0c1c9064051f1e7d78ac8afd04e Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 15 Nov 2016 18:19:01 +0100 Subject: [PATCH 2/2] Revert "Report git-hash used to package the distribution - Closes #1319" This reverts commit 209fc4c7b68db69103630ff87c90f840afe7d1c1. --- project/Build.scala | 4 ---- .../tools/dotc/repl/InterpreterLoop.scala | 3 +-- src/dotty/tools/dotc/repl/ManifestInfo.scala | 20 ------------------- 3 files changed, 1 insertion(+), 26 deletions(-) delete mode 100644 src/dotty/tools/dotc/repl/ManifestInfo.scala diff --git a/project/Build.scala b/project/Build.scala index 5b8465b4e6ec..7c57bd8621d0 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -6,7 +6,6 @@ import scala.reflect.io.Path import org.scalajs.sbtplugin.ScalaJSPlugin import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._ -import sbt.Package.ManifestAttributes object DottyBuild extends Build { @@ -173,9 +172,6 @@ object DottyBuild extends Build { fork in Test := true, parallelExecution in Test := false, - // Add git-hash used to package the distribution to the manifest to know it in runtime and report it in REPL - packageOptions += ManifestAttributes(("Git-Hash", VersionUtil.gitHash)), - // http://grokbase.com/t/gg/simple-build-tool/135ke5y90p/sbt-setting-jvm-boot-paramaters-for-scala javaOptions <++= (dependencyClasspath in Runtime, packageBin in Compile) map { (attList, bin) => // put the Scala {library, reflect} in the classpath diff --git a/src/dotty/tools/dotc/repl/InterpreterLoop.scala b/src/dotty/tools/dotc/repl/InterpreterLoop.scala index b3ac41c55c12..8b1000f2e207 100644 --- a/src/dotty/tools/dotc/repl/InterpreterLoop.scala +++ b/src/dotty/tools/dotc/repl/InterpreterLoop.scala @@ -66,8 +66,7 @@ class InterpreterLoop(compiler: Compiler, config: REPL.Config)(implicit ctx: Con output.flush() } - val gitHash = ManifestInfo.attributes.getOrElse("Git-Hash", "unknown") - val version = s".next (pre-alpha, git-hash: $gitHash)" + val version = ".next (pre-alpha)" /** The main read-eval-print loop for the interpreter. It calls * `command()` for each line of input. diff --git a/src/dotty/tools/dotc/repl/ManifestInfo.scala b/src/dotty/tools/dotc/repl/ManifestInfo.scala deleted file mode 100644 index 206dccd67075..000000000000 --- a/src/dotty/tools/dotc/repl/ManifestInfo.scala +++ /dev/null @@ -1,20 +0,0 @@ -package dotty.tools.dotc.repl - -import java.net.JarURLConnection -import scala.collection.JavaConversions._ - -object ManifestInfo { - - val attributes: Map[String, String] = { - for { - resourceUrl <- Option(getClass.getResource(getClass.getSimpleName + ".class")) - urlConnection = resourceUrl.openConnection() if urlConnection.isInstanceOf[JarURLConnection] - manifest <- Option(urlConnection.asInstanceOf[JarURLConnection].getManifest) - } yield { - manifest.getMainAttributes.foldLeft(Map[String, String]())( - (map, attribute) => map + (attribute._1.toString -> attribute._2.toString) - ) - } - }.getOrElse(Map()) - -}