Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Scala to 2.13 #1522

Merged
merged 18 commits into from
Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import sbtcrossproject.CrossPlugin.autoImport.crossProject

def scala211 = "2.11.12"
def scala212 = "2.12.8"
def scala213 = "2.13.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def scala213 = "2.13.0"
def scala213 = "2.13.1"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unpleasant discovery: scalafmt should have similar Scala version with coursier-interface for assembly working 😒

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate? I thought scala-library was shaded with coursier-interface

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem in reflect.properties file (#1514 (comment)). coursier-interface jar contains file with content:

#Fri Jun 07 10:55:45 UTC 2019
shell.banner=%n     ________ ___   / /  ___%n    / __/ __// _ | / /  / _ |%n  __\\ \\/ /__/ __ |/ /__/ __ |%n /____/\\___/_/ |_/____/_/ | |%n                          |/  %s
copyright.string=Copyright 2002-2019, LAMP/EPFL and Lightbend, Inc.
version.number=2.13.0
osgi.version.number=2.13.0.v20190604-151517-VFINAL-43e040f
maven.version.number=2.13.0

But I hope that we can add sbt-assembly rule to discard scala-reflect from coursier-interface.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be fine to discard the reflect.properties file from coursier-interface, unless the code from that scala-library somehow relies on APIs like scala.util.Properties.versionNumberString.


inThisBuild(
List(
Expand All @@ -19,8 +20,8 @@ inThisBuild(
url("https://geirsson.com")
)
),
scalaVersion := scala212,
crossScalaVersions := List(scala212, scala211),
scalaVersion := scala213,
crossScalaVersions := List(scala213, scala212, scala211),
resolvers += Resolver.sonatypeRepo("releases"),
libraryDependencies ++= List(
scalatest.value % Test,
Expand Down Expand Up @@ -89,10 +90,8 @@ lazy val core = crossProject(JVMPlatform)
.in(file("scalafmt-core"))
.settings(
moduleName := "scalafmt-core",
addCompilerPlugin(
poslegm marked this conversation as resolved.
Show resolved Hide resolved
"org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full
),
buildInfoSettings,
scalacOptions ++= scalacJvmOptions.value,
libraryDependencies ++= Seq(
metaconfig.value,
scalameta.value,
Expand Down Expand Up @@ -122,6 +121,7 @@ import sbtassembly.AssemblyPlugin.defaultUniversalScript
val scalacJvmOptions = Def.setting {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) => Seq("-target:jvm-1.8")
case Some((2, 13)) => Seq("-Ymacro-annotations")
case _ => Seq.empty
}
}
Expand Down
6 changes: 3 additions & 3 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._
// scalafmt: { maxColumn = 120, style = defaultWithAlign }

object Dependencies {
val metaconfigV = "0.8.3"
val metaconfigV = "0.9.4"
val scalametaV = "4.2.3"
val scalatestV = "3.2.0-SNAP10"
val scalacheckV = "1.13.5"
val scalatestV = "3.0.8"
val scalacheckV = "1.14.2"
val coursier = "1.0.3"

val scalapb = Def.setting {
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.2.6
sbt.version=1.3.2
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ object ScalafmtCoreRunner extends ScalafmtRunner {
val termDisplay =
newTermDisplay(options, inputMethods, termDisplayMessage)
val exitCode = new AtomicReference(ExitCode.Ok)
inputMethods.par.foreach { inputMethod =>
// TODO add parallel collections
poslegm marked this conversation as resolved.
Show resolved Hide resolved
inputMethods.foreach { inputMethod =>
val code = handleFile(inputMethod, options, scalafmtConf)
exitCode.getAndUpdate(new UnaryOperator[ExitCode] {
override def apply(t: ExitCode): ExitCode =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ object Terminal {
None

implicit class Ansi(val output: Writer) extends AnyVal {
private def control(n: Int, c: Char) = output.write(s"\033[" + n + c)
private def control(n: Int, c: Char) = output.write(s"\\033[" + n + c)

/**
* Move up `n` squares
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trait ScalafmtConfDecoders {
implicit lazy val eventReader: ConfDecoder[FormatEvent => Unit] =
ConfDecoder.instance[FormatEvent => Unit] {
case _ =>
Configured.Ok((_: FormatEvent) => Unit)
Configured.Ok((_: FormatEvent) => ())
}
implicit lazy val parseReader: ConfDecoder[MetaParser] = {
ReaderUtil.oneOf[MetaParser](parseSource, parseStat, parseCase)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import scala.meta.parsers.Parse
*/
case class ScalafmtRunner(
debug: Boolean = false,
eventCallback: FormatEvent => Unit = _ => Unit,
eventCallback: FormatEvent => Unit = _ => (),
parser: Parse[_ <: Tree] = Parse.parseSource,
optimizer: ScalafmtOptimizer = ScalafmtOptimizer.default,
maxStateVisits: Int = 1000000,
Expand Down Expand Up @@ -84,7 +84,7 @@ object ScalafmtRunner {
*/
val default = ScalafmtRunner(
debug = false,
eventCallback = _ => Unit,
eventCallback = _ => (),
parser = scala.meta.parsers.Parse.parseSource,
optimizer = ScalafmtOptimizer.default,
maxStateVisits = 1000000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import scala.meta.Tree
import scala.meta.Type
import scala.meta.prettyprinters.Structure
import scala.meta.tokens.Token
import scala.meta.tokens.Token._
import scala.meta.tokens.Token.{Space => _, _}
poslegm marked this conversation as resolved.
Show resolved Hide resolved
import org.scalafmt.Error.CaseMissingArrow
import org.scalafmt.config.{
DanglingExclude,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import scala.meta.Tree
import scala.meta.Type
import scala.meta.prettyprinters.Syntax
import scala.meta.tokens.Token
import scala.meta.tokens.Token._
import scala.meta.tokens.Token.{Space => _, _}
import java.util.regex.Pattern

import org.scalafmt.internal.FormatWriter.FormatLocation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import scala.meta.{
}

// Too many to import individually.
import scala.meta.tokens.Token._
import scala.meta.tokens.Token.{Space => _, _}
poslegm marked this conversation as resolved.
Show resolved Hide resolved

object Constants {
val ShouldBeNewline = 100000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ object Patch {
(tokenPatches)
.groupBy(t => t.tok.start -> t.tok.end)
.mapValues(_.reduce(merge).newTok)
.toMap
input.toIterator
.map(x => patchMap.getOrElse(x.start -> x.end, x.syntax))
.mkString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object Rewrite {
)

private def nameMap[T](t: sourcecode.Text[T]*): Map[String, T] = {
t.map(x => x.source -> x.value)(scala.collection.breakOut)
t.view.map(x => x.source -> x.value).toMap
}

val name2rewrite: Map[String, Rewrite] = nameMap[Rewrite](
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class GitOpsImpl(private[util] val workingDirectory: AbsoluteFile)
private[util] def exec(cmd: Seq[String]): Try[Seq[String]] = {
val gitRes: Try[String] = Try {
val lastError = new StringBuilder
val swallowStderr = ProcessLogger(_ => Unit, err => lastError.append(err))
val swallowStderr = ProcessLogger(_ => (), err => lastError.append(err))
try {
sys.process
.Process(cmd, workingDirectory.jfile)
Expand Down