From 301ec787f2f17367064cda5eef3a9009ba66e21f Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Wed, 16 Nov 2016 10:11:41 +0000 Subject: [PATCH] Drop "serialising" Function1. It's easily fallible --- .../src/main/datatype/librarymanagement.json | 8 +------ .../formats/Function1Format.scala | 8 ------- .../sbt/librarymanagement/CrossVersion.scala | 23 ++++--------------- .../sbt/librarymanagement/ModuleID.scala | 3 --- project/DatatypeConfig.scala | 3 --- 5 files changed, 5 insertions(+), 40 deletions(-) delete mode 100644 librarymanagement/src/main/scala/sbt/internal/librarymanagement/formats/Function1Format.scala diff --git a/librarymanagement/src/main/datatype/librarymanagement.json b/librarymanagement/src/main/datatype/librarymanagement.json index 7e01e4424..940f65d2d 100644 --- a/librarymanagement/src/main/datatype/librarymanagement.json +++ b/librarymanagement/src/main/datatype/librarymanagement.json @@ -315,10 +315,7 @@ "For example, if `remapVersion = v => \"2.10\"` and the binary version is \"2.9.2\" or \"2.10\",", "the module is cross-versioned with \"2.10\"." ], - "type": "record", - "fields": [ - { "name": "remapVersion", "type": "Function1[String, String]" } - ] + "type": "record" }, { "name": "Full", @@ -329,9 +326,6 @@ "Cross-versions a module with the result of applying `remapVersion` to the full version.", "For example, if `remapVersion = v => \"2.10\"` and the full version is \"2.9.2\" or \"2.10.3\",", "the module is cross-versioned with \"2.10\"." - ], - "fields": [ - { "name": "remapVersion", "type": "Function1[String, String]" } ] } ], diff --git a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/formats/Function1Format.scala b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/formats/Function1Format.scala deleted file mode 100644 index 12f4f2f94..000000000 --- a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/formats/Function1Format.scala +++ /dev/null @@ -1,8 +0,0 @@ -package sbt.internal.librarymanagement.formats - -import sjsonnew._ - -trait Function1Format { self: BasicJsonProtocol => - implicit def Function1Format[T, U]: JsonFormat[T => U] = - project(MyCrazyReferences.referenced _, (ref: String) => MyCrazyReferences(ref, classOf[T => U])) -} diff --git a/librarymanagement/src/main/scala/sbt/librarymanagement/CrossVersion.scala b/librarymanagement/src/main/scala/sbt/librarymanagement/CrossVersion.scala index 77cf913ed..d212e0e0a 100644 --- a/librarymanagement/src/main/scala/sbt/librarymanagement/CrossVersion.scala +++ b/librarymanagement/src/main/scala/sbt/librarymanagement/CrossVersion.scala @@ -13,25 +13,10 @@ abstract class CrossVersionFunctions { val TransitionSbtVersion = CrossVersionUtil.TransitionSbtVersion /** Cross-versions a module with the full version (typically the full Scala version). */ - def full: CrossVersion = new Full(idStringFun) - - /** - * Cross-versions a module with the result of applying `remapVersion` to the full version - * (typically the full Scala version). See also [[sbt.librarymanagement.CrossVersion.Full]]. - */ - def fullMapped(remapVersion: String => String): CrossVersion = new Full(remapVersion) + def full: CrossVersion = new Full() /** Cross-versions a module with the binary version (typically the binary Scala version). */ - def binary: CrossVersion = new Binary(idStringFun) - - /** - * Cross-versions a module with the result of applying `remapVersion` to the binary version - * (typically the binary Scala version). See also [[sbt.librarymanagement.CrossVersion.Binary]]. - */ - def binaryMapped(remapVersion: String => String): CrossVersion = new Binary(remapVersion) - - private[this] def idFun[T]: T => T = x => x - private[this] val idStringFun = idFun[String] + def binary: CrossVersion = new Binary() private[sbt] def append(s: String): Option[String => String] = Some(x => crossName(x, s)) @@ -43,8 +28,8 @@ abstract class CrossVersionFunctions { def apply(cross: CrossVersion, fullVersion: String, binaryVersion: String): Option[String => String] = cross match { case _: Disabled => None - case b: Binary => append(b.remapVersion(binaryVersion)) - case f: Full => append(f.remapVersion(fullVersion)) + case _: Binary => append(binaryVersion) + case _: Full => append(fullVersion) } /** Constructs the cross-version function defined by `module` and `is`, if one is configured. */ diff --git a/librarymanagement/src/main/scala/sbt/librarymanagement/ModuleID.scala b/librarymanagement/src/main/scala/sbt/librarymanagement/ModuleID.scala index d3bb3feaa..e4f12fd3d 100644 --- a/librarymanagement/src/main/scala/sbt/librarymanagement/ModuleID.scala +++ b/librarymanagement/src/main/scala/sbt/librarymanagement/ModuleID.scala @@ -47,9 +47,6 @@ abstract class ModuleIDExtra { @deprecated("Use `cross(CrossVersion)`, the variant accepting a CrossVersion value constructed by a member of the CrossVersion object instead.", "0.12.0") def cross(v: Boolean): ModuleID = cross(if (v) CrossVersion.binary else Disabled()) - @deprecated("Use `cross(CrossVersion)`, the variant accepting a CrossVersion value constructed by a member of the CrossVersion object instead.", "0.12.0") - def cross(v: Boolean, verRemap: String => String): ModuleID = cross(if (v) CrossVersion.binaryMapped(verRemap) else Disabled()) - /** Specifies the cross-version behavior for this module. See [CrossVersion] for details.*/ def cross(v: CrossVersion): ModuleID = copy(crossVersion = v) diff --git a/project/DatatypeConfig.scala b/project/DatatypeConfig.scala index a83fb618a..78159c476 100644 --- a/project/DatatypeConfig.scala +++ b/project/DatatypeConfig.scala @@ -20,9 +20,6 @@ object DatatypeConfig { val myCodecs: PartialFunction[String, TpeRef => List[String]] = { case "java.util.Date" => { _ => "sbt.internal.librarymanagement.formats.DateFormat" :: Nil } - case "Function1" => - { tpe => "sbt.internal.librarymanagement.formats.Function1Format" :: twoArgs(tpe).flatMap(getFormats) } - case "scala.xml.NodeSeq" => { _ => "sbt.internal.librarymanagement.formats.NodeSeqFormat" :: Nil } case "org.apache.ivy.plugins.resolver.DependencyResolver" =>