From f7300a000fe7c9ed9d5cfa22c3e2d06c14f20b13 Mon Sep 17 00:00:00 2001 From: Roberto Tyley Date: Mon, 17 Jun 2019 21:45:45 +0100 Subject: [PATCH] Upgrade to Scala 2.13 https://docs.scala-lang.org/overviews/core/collections-migration-213.html See also https://github.com/scala/bug/issues/11245 --- build.sbt | 4 ++-- project/Dependencies.scala | 2 +- .../src/main/scala/com/madgag/diff/MapDiff.scala | 6 +++--- .../src/main/scala/com/madgag/git/model/Tree.scala | 14 +++++++------- .../src/main/scala/com/madgag/git/package.scala | 2 +- .../scala/com/madgag/git/ReachableBlobSpec.scala | 2 +- .../scala/com/madgag/git/RichTreeWalkSpec.scala | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/build.sbt b/build.sbt index ec04f80..dc571ae 100644 --- a/build.sbt +++ b/build.sbt @@ -1,8 +1,8 @@ import ReleaseTransformations._ lazy val baseSettings = Seq( - scalaVersion := "2.12.8", - crossScalaVersions := Seq(scalaVersion.value, "2.11.12"), + scalaVersion := "2.13.0", + crossScalaVersions := Seq(scalaVersion.value, "2.12.8"), organization := "com.madgag.scala-git", scmInfo := Some(ScmInfo( url("https://github.com/rtyley/scala-git"), diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 67e0ad9..f69e5c4 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -6,7 +6,7 @@ object Dependencies { val eclipseJgit = "org.eclipse.jgit" % "org.eclipse.jgit" % "4.0.1.201506240215-r" val jgit = eclipseJgit - val scalatest = "org.scalatest" %% "scalatest" % "3.0.4" + val scalatest = "org.scalatest" %% "scalatest" % "3.0.8" val madgagCompress = "com.madgag" % "util-compress" % "1.33" diff --git a/scala-git/src/main/scala/com/madgag/diff/MapDiff.scala b/scala-git/src/main/scala/com/madgag/diff/MapDiff.scala index bf12eaa..c1eea31 100644 --- a/scala-git/src/main/scala/com/madgag/diff/MapDiff.scala +++ b/scala-git/src/main/scala/com/madgag/diff/MapDiff.scala @@ -10,14 +10,14 @@ case class MapDiff[K, V](beforeAndAfter: Map[BeforeAndAfter, Map[K,V]]) { lazy val commonElements: Set[K] = beforeAndAfter.values.map(_.keySet).reduce(_ intersect _) lazy val only: Map[BeforeAndAfter, Map[K,V]] = - beforeAndAfter.mapValues(_.filterKeys(!commonElements(_))) + beforeAndAfter.mapValues(_.filterKeys(!commonElements(_)).toMap).toMap lazy val (unchanged, changed) = commonElements.partition(k => beforeAndAfter(Before)(k) == beforeAndAfter(After)(k)) - lazy val unchangedMap: Map[K,V] = beforeAndAfter(Before).filterKeys(unchanged) + lazy val unchangedMap: Map[K,V] = beforeAndAfter(Before).filterKeys(unchanged).toMap lazy val changedMap: Map[K,Map[BeforeAndAfter, V]] = - changed.map(k => k -> beforeAndAfter.mapValues(_(k))).toMap + changed.map(k => k -> beforeAndAfter.mapValues(_(k)).toMap).toMap } \ No newline at end of file diff --git a/scala-git/src/main/scala/com/madgag/git/model/Tree.scala b/scala-git/src/main/scala/com/madgag/git/model/Tree.scala index 28be9e9..fb17abf 100644 --- a/scala-git/src/main/scala/com/madgag/git/model/Tree.scala +++ b/scala-git/src/main/scala/com/madgag/git/model/Tree.scala @@ -28,7 +28,7 @@ object Tree { val Empty = Tree(Map.empty[FileName, (FileMode, ObjectId)]) - def apply(entries: Traversable[Tree.Entry]): Tree = Tree(entries.map { + def apply(entries: Iterable[Tree.Entry]): Tree = Tree(entries.map { entry => entry.name -> ((entry.fileMode, entry.objectId)) }.toMap) @@ -42,7 +42,7 @@ object Tree { entries += Entry(treeParser) treeParser.next() } - entries + entries.toSeq } case class Entry(name: FileName, fileMode: FileMode, objectId: ObjectId) extends Ordered[Entry] { @@ -91,7 +91,7 @@ case class Tree(entryMap: Map[FileName, (FileMode, ObjectId)]) { protected def repr = this - lazy val entries = entryMap.map { + lazy val entries: Iterable[Tree.Entry] = entryMap.map { case (name, (fileMode, objectId)) => Tree.Entry(name, fileMode, objectId) } @@ -134,19 +134,19 @@ case class TreeBlobEntry(filename: FileName, mode: BlobFileMode, objectId: Objec object TreeBlobs { import language.implicitConversions - implicit def entries2Object(entries: Traversable[TreeBlobEntry]) = TreeBlobs(entries) + implicit def entries2Object(entries: Iterable[TreeBlobEntry]) = TreeBlobs(entries) - def apply(entries: Traversable[TreeBlobEntry]): TreeBlobs = + def apply(entries: Iterable[TreeBlobEntry]): TreeBlobs = TreeBlobs(entries.map(e => e.filename -> ((e.mode, e.objectId))).toMap) } case class TreeBlobs(entryMap: Map[FileName, (BlobFileMode, ObjectId)]) extends Tree.EntryGrouping { - lazy val entries = entryMap.map { + lazy val entries: Iterable[TreeBlobEntry] = entryMap.map { case (name, (blobFileMode, objectId)) => TreeBlobEntry(name, blobFileMode, objectId) } - lazy val treeEntries = entries.map(_.toTreeEntry) + lazy val treeEntries: Iterable[Tree.Entry] = entries.map(_.toTreeEntry) def objectId(fileName: FileName) = entryMap.get(fileName).map(_._2) diff --git a/scala-git/src/main/scala/com/madgag/git/package.scala b/scala-git/src/main/scala/com/madgag/git/package.scala index 427cc9f..e7950cd 100644 --- a/scala-git/src/main/scala/com/madgag/git/package.scala +++ b/scala-git/src/main/scala/com/madgag/git/package.scala @@ -262,7 +262,7 @@ package object git { } def diff(trees: RevTree*)(implicit reader: ObjectReader): Seq[DiffEntry] = - DiffEntry.scan(walk(trees: _*)(TreeFilter.ANY_DIFF)).asScala + DiffEntry.scan(walk(trees: _*)(TreeFilter.ANY_DIFF)).asScala.toSeq def allBlobsUnder(tree: RevTree)(implicit reader: ObjectReader): Set[ObjectId] = tree.walk().map(_.getObjectId(0)).toSet diff --git a/scala-git/src/test/scala/com/madgag/git/ReachableBlobSpec.scala b/scala-git/src/test/scala/com/madgag/git/ReachableBlobSpec.scala index f46d252..0e74b92 100644 --- a/scala-git/src/test/scala/com/madgag/git/ReachableBlobSpec.scala +++ b/scala-git/src/test/scala/com/madgag/git/ReachableBlobSpec.scala @@ -18,7 +18,7 @@ package com.madgag.git import org.scalatest.{FlatSpec, Matchers} import com.madgag.git.test._ - +import scala.language.postfixOps class ReachableBlobSpec extends FlatSpec with Matchers { diff --git a/scala-git/src/test/scala/com/madgag/git/RichTreeWalkSpec.scala b/scala-git/src/test/scala/com/madgag/git/RichTreeWalkSpec.scala index 4dde0c0..dad8392 100644 --- a/scala-git/src/test/scala/com/madgag/git/RichTreeWalkSpec.scala +++ b/scala-git/src/test/scala/com/madgag/git/RichTreeWalkSpec.scala @@ -43,7 +43,7 @@ class RichTreeWalkSpec extends FlatSpec with Matchers { fileNameList should have size 6 - fileNameList.groupBy(identity).mapValues(_.size) should contain ("zero" -> 2) + fileNameList.groupBy(identity).mapValues(_.size).toMap should contain ("zero" -> 2) } it should "implement withFilter" in {