mirror of https://github.com/sbt/sbt.git
Disable pattern matching in val syntax in sbt 0.13.7.
Fixes #1661 or at least works around it for now.
This commit is contained in:
parent
e8b91e4e7e
commit
ddf8a173b0
|
|
@ -92,6 +92,21 @@ private[sbt] case class SbtParser(file: File, lines: Seq[String]) extends Parsed
|
|||
Seq(t)
|
||||
}
|
||||
|
||||
// Check No val (a,b) = foo *or* val a,b = foo as these are problematic to range positions and the WHOLE architecture.
|
||||
def isBadValDef(t: Tree): Boolean =
|
||||
t match {
|
||||
case (x @ (toolbox.u.ValDef(_, _, _, _) | toolbox.u.DefDef(_, _, _, _, _, _))) =>
|
||||
val content = modifiedContent.substring(x.pos.start, x.pos.end)
|
||||
val prettyPrint = x.toString
|
||||
(!(content contains "=") && (prettyPrint contains "="))
|
||||
case _ => false
|
||||
}
|
||||
parsedTrees.filter(isBadValDef).foreach { badTree =>
|
||||
// Issue errors
|
||||
val positionLine = badTree.pos.line
|
||||
throw new MessageOnlyException(s"""[$fileName]:$positionLine: Pattern matching in val statements is not supported""".stripMargin)
|
||||
}
|
||||
|
||||
val (imports, statements) = parsedTrees partition {
|
||||
case _: Import => true
|
||||
case _ => false
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
val a,b = project
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
val x = bar
|
||||
|
||||
{
|
||||
val a,b = project
|
||||
}
|
||||
|
|
@ -134,6 +134,7 @@ abstract class AbstractSplitExpressionsFilesTest(pathName: String) extends Speci
|
|||
println(s"In file: $fileName, old splitter failed. ${ex.toString}")
|
||||
case SplitterComparison(_, util.Failure(ex)) =>
|
||||
println(s"In file: $fileName, new splitter failed. ${ex.toString}")
|
||||
ex.printStackTrace()
|
||||
case SplitterComparison(util.Success(resultOld), util.Success(resultNew)) =>
|
||||
if (resultOld == resultNew) {
|
||||
println(s"In file: $fileName, same results (imports, settings): $resultOld")
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
lazy val a,b = project
|
||||
|
||||
def now = System.currentTimeMillis
|
||||
|
||||
lazy val v = "1.0-" +
|
||||
|
|
@ -10,3 +12,5 @@ val descr = "Description"
|
|||
name := n
|
||||
|
||||
version := v
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue