From 3aa6b1d2a4710cff28b992c939903446533e54a3 Mon Sep 17 00:00:00 2001 From: xuwei-k <6b656e6a69@gmail.com> Date: Mon, 1 Jan 2024 07:56:34 +0900 Subject: [PATCH] enforce new wildcard syntax --- .scalafmt.conf | 5 +++++ build.sbt | 6 +++--- .../scala-3.0-/eu/timepit/refined/boolean.scala | 2 +- .../scala-3.0-/eu/timepit/refined/collection.scala | 4 ++-- .../eu/timepit/refined/internal/Resources.scala | 14 +++++++------- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index bc14b33a5..54e751790 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -9,5 +9,10 @@ rewriteTokens { fileOverride { "glob:**/src/*/scala-3.0+/**" { runner.dialect = scala3 + rewrite.scala3.convertToNewSyntax = false } } +rewrite.scala3.convertToNewSyntax = true +runner.dialectOverride.allowAsForImportRename = false +runner.dialectOverride.allowStarWildcardImport = false +runner.dialectOverride.allowPostfixStarVarargSplices = false diff --git a/build.sbt b/build.sbt index 2449174db..b73fa1e7f 100644 --- a/build.sbt +++ b/build.sbt @@ -364,7 +364,7 @@ lazy val moduleCrossSettings = Def.settings( commonSettings ) -def moduleJvmSettings(name: String): Seq[Def.Setting[_]] = +def moduleJvmSettings(name: String): Seq[Def.Setting[?]] = Def.settings( scalaVersion := Scala_2_13, javaOptions ++= Seq("-Duser.language=en"), @@ -385,7 +385,7 @@ def moduleJvmSettings(name: String): Seq[Def.Setting[_]] = } ) -def moduleJsSettings(name: String): Seq[Def.Setting[_]] = +def moduleJsSettings(name: String): Seq[Def.Setting[?]] = Def.settings( scalaVersion := Scala_2_13, crossScalaVersions := moduleCrossScalaVersionsMatrix(name, JSPlatform), @@ -403,7 +403,7 @@ def moduleJsSettings(name: String): Seq[Def.Setting[_]] = } ) -def moduleNativeSettings(name: String): Seq[Def.Setting[_]] = +def moduleNativeSettings(name: String): Seq[Def.Setting[?]] = Def.settings( crossScalaVersions := moduleCrossScalaVersionsMatrix(name, NativePlatform), doctestGenTests := Seq.empty, diff --git a/modules/core/shared/src/main/scala-3.0-/eu/timepit/refined/boolean.scala b/modules/core/shared/src/main/scala-3.0-/eu/timepit/refined/boolean.scala index d7472b5e7..8a6613428 100644 --- a/modules/core/shared/src/main/scala-3.0-/eu/timepit/refined/boolean.scala +++ b/modules/core/shared/src/main/scala-3.0-/eu/timepit/refined/boolean.scala @@ -235,7 +235,7 @@ object boolean extends BooleanInference0 { implicit def oneOfHConsValidate[T, PH, RH, PT <: HList, RT <: HList](implicit vh: Validate.Aux[T, PH, RH], vt: Validate.Aux[T, OneOf[PT], OneOf[RT]], - toList: ToList[RT, Result[_]] + toList: ToList[RT, Result[?]] ): Validate.Aux[T, OneOf[PH :: PT], OneOf[vh.Res :: RT]] = new Validate[T, OneOf[PH :: PT]] { override type R = OneOf[vh.Res :: RT] diff --git a/modules/core/shared/src/main/scala-3.0-/eu/timepit/refined/collection.scala b/modules/core/shared/src/main/scala-3.0-/eu/timepit/refined/collection.scala index e3fd386f2..8b466491b 100644 --- a/modules/core/shared/src/main/scala-3.0-/eu/timepit/refined/collection.scala +++ b/modules/core/shared/src/main/scala-3.0-/eu/timepit/refined/collection.scala @@ -122,7 +122,7 @@ object collection extends CollectionInference { } object Empty { - implicit def emptyValidate[T](implicit ev: T => Iterable[_]): Validate.Plain[T, Empty] = + implicit def emptyValidate[T](implicit ev: T => Iterable[?]): Validate.Plain[T, Empty] = Validate.fromPredicate(t => ev(t).isEmpty, t => s"isEmpty($t)", Empty()) } @@ -254,7 +254,7 @@ object collection extends CollectionInference { object Size { implicit def sizeValidate[T, P, RP](implicit v: Validate.Aux[Int, P, RP], - ev: T => Iterable[_] + ev: T => Iterable[?] ): Validate.Aux[T, Size[P], Size[v.Res]] = new Validate[T, Size[P]] { override type R = Size[v.Res] diff --git a/modules/core/shared/src/main/scala/eu/timepit/refined/internal/Resources.scala b/modules/core/shared/src/main/scala/eu/timepit/refined/internal/Resources.scala index ba895d379..d85ea9829 100644 --- a/modules/core/shared/src/main/scala/eu/timepit/refined/internal/Resources.scala +++ b/modules/core/shared/src/main/scala/eu/timepit/refined/internal/Resources.scala @@ -15,16 +15,16 @@ object Resources { val Left = "Left" val Right = "Right" - def predicateResult(r: Result[_]): String = + def predicateResult(r: Result[?]): String = s"$Predicate ${toLowerCase(r)}" - def predicateResultDetail(r: Result[_], detail: String): String = + def predicateResultDetail(r: Result[?], detail: String): String = s"${predicateResult(r)}: $detail" - def predicateResultDetailDot(r: Result[_], detail: String): String = + def predicateResultDetailDot(r: Result[?], detail: String): String = s"${predicateResultDetail(r, detail)}." - def predicateTakingResultDetail(taking: String, r: Result[_], detail: String): String = + def predicateTakingResultDetail(taking: String, r: Result[?], detail: String): String = s"$Predicate taking $taking ${toLowerCase(r)}: $detail" def showExprEmptyCollection: String = @@ -33,10 +33,10 @@ object Resources { def showResultEmptyCollection: String = s"$Predicate $failed: empty collection." - def namePredicateResult(name: String, r: Result[_]): String = + def namePredicateResult(name: String, r: Result[?]): String = s"$name $predicate ${toLowerCase(r)}" - def namePredicateResultMessage(name: String, r: Result[_], maybeThrowable: Try[_]): String = { + def namePredicateResultMessage(name: String, r: Result[?], maybeThrowable: Try[?]): String = { val suffix = maybeThrowable match { case Success(_) => "." case Failure(e) => s": ${e.getMessage}" @@ -47,7 +47,7 @@ object Resources { def isValidName[T](name: String, t: T): String = s"""isValid$name("$t")""" - def toLowerCase(r: Result[_]): String = + def toLowerCase(r: Result[?]): String = r.morph(passed, failed) // Not