diff --git a/.scalafmt.conf b/.scalafmt.conf index 348d8240c0..6936060968 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -26,3 +26,8 @@ fileOverride { project.excludeFilters = [ "scalafix/*" ] +rewrite.scala3.convertToNewSyntax = true +runner.dialectOverride.allowSignificantIndentation = false +runner.dialectOverride.allowAsForImportRename = false +runner.dialectOverride.allowStarWildcardImport = false +runner.dialectOverride.allowPostfixStarVarargSplices = false diff --git a/algebra-core/src/main/scala/algebra/ring/Additive.scala b/algebra-core/src/main/scala/algebra/ring/Additive.scala index 94d3081d4c..dba76626e1 100644 --- a/algebra-core/src/main/scala/algebra/ring/Additive.scala +++ b/algebra-core/src/main/scala/algebra/ring/Additive.scala @@ -155,7 +155,7 @@ trait AdditiveCommutativeGroup[@sp(Int, Long, Float, Double) A] trait AdditiveSemigroupFunctions[S[T] <: AdditiveSemigroup[T]] { def isAdditiveCommutative[A](implicit ev: S[A]): Boolean = - ev.isInstanceOf[AdditiveCommutativeSemigroup[_]] + ev.isInstanceOf[AdditiveCommutativeSemigroup[?]] def plus[@sp(Int, Long, Float, Double) A](x: A, y: A)(implicit ev: S[A]): A = ev.plus(x, y) diff --git a/build.sbt b/build.sbt index a4c074f4a4..7435e94297 100644 --- a/build.sbt +++ b/build.sbt @@ -121,12 +121,12 @@ lazy val kernelLaws = crossProject(JSPlatform, JVMPlatform, NativePlatform) .jvmSettings(commonJvmSettings) .nativeSettings(commonNativeSettings) -lazy val algebraSettings = Seq[Setting[_]]( +lazy val algebraSettings = Seq[Setting[?]]( tlMimaPreviousVersions += "2.2.3", tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "2.7.0").toMap ) -lazy val algebraNativeSettings = Seq[Setting[_]]( +lazy val algebraNativeSettings = Seq[Setting[?]]( tlMimaPreviousVersions ~= (_ - "2.2.3"), tlVersionIntroduced += ("3" -> "2.8.0") ) diff --git a/core/src/main/scala/cats/ApplicativeError.scala b/core/src/main/scala/cats/ApplicativeError.scala index 624a9c32e9..7582fca4ed 100644 --- a/core/src/main/scala/cats/ApplicativeError.scala +++ b/core/src/main/scala/cats/ApplicativeError.scala @@ -365,7 +365,7 @@ object ApplicativeError { def apply[F[_], E](implicit F: ApplicativeError[F, E]): ApplicativeError[F, E] = F final private[cats] class LiftFromOptionPartially[F[_]](private val dummy: Boolean = true) extends AnyVal { - def apply[E, A](oa: Option[A], ifEmpty: => E)(implicit F: ApplicativeError[F, _ >: E]): F[A] = + def apply[E, A](oa: Option[A], ifEmpty: => E)(implicit F: ApplicativeError[F, ? >: E]): F[A] = oa match { case Some(a) => F.pure(a) case None => F.raiseError(ifEmpty) diff --git a/core/src/main/scala/cats/data/Chain.scala b/core/src/main/scala/cats/data/Chain.scala index b8b882e8b4..69c0d2da5e 100644 --- a/core/src/main/scala/cats/data/Chain.scala +++ b/core/src/main/scala/cats/data/Chain.scala @@ -165,7 +165,7 @@ sealed abstract class Chain[+A] extends ChainCompat[A] { /** * Returns true if there are no elements in this collection. */ - def isEmpty: Boolean = !this.isInstanceOf[Chain.NonEmpty[_]] + def isEmpty: Boolean = !this.isInstanceOf[Chain.NonEmpty[?]] /** * Returns false if there are no elements in this collection. @@ -174,7 +174,7 @@ sealed abstract class Chain[+A] extends ChainCompat[A] { // Quick check whether the chain is either empty or contains one element only. @inline private def isEmptyOrSingleton: Boolean = - isEmpty || this.isInstanceOf[Chain.Singleton[_]] + isEmpty || this.isInstanceOf[Chain.Singleton[?]] /** * Concatenates this with `c` in O(1) runtime. @@ -863,7 +863,7 @@ sealed abstract class Chain[+A] extends ChainCompat[A] { override def equals(o: Any): Boolean = o match { - case thatChain: Chain[_] => + case thatChain: Chain[?] => (this: Chain[Any]).===(thatChain: Chain[Any])(Eq.fromUniversalEquals[Any]) case _ => false } diff --git a/core/src/main/scala/cats/data/EitherT.scala b/core/src/main/scala/cats/data/EitherT.scala index 3ee00822d7..b2432c0cd5 100644 --- a/core/src/main/scala/cats/data/EitherT.scala +++ b/core/src/main/scala/cats/data/EitherT.scala @@ -150,7 +150,7 @@ final case class EitherT[F[_], A, B](value: F[Either[A, B]]) { * res0: Try[Int] = Failure(java.lang.RuntimeException: ERROR!) * }}} */ - def getOrRaise[E](e: => E)(implicit F: MonadError[F, _ >: E]): F[B] = + def getOrRaise[E](e: => E)(implicit F: MonadError[F, ? >: E]): F[B] = getOrElseF(F.raiseError(e)) /** @@ -248,7 +248,7 @@ final case class EitherT[F[_], A, B](value: F[Either[A, B]]) { * res3: util.Try[String] = Failure(java.lang.Exception: sad cats) * }}} */ - def rethrowT(implicit F: MonadError[F, _ >: A]): F[B] = + def rethrowT(implicit F: MonadError[F, ? >: A]): F[B] = F.rethrow(value) /** diff --git a/core/src/main/scala/cats/data/IorT.scala b/core/src/main/scala/cats/data/IorT.scala index 45712b664f..1b493635e9 100644 --- a/core/src/main/scala/cats/data/IorT.scala +++ b/core/src/main/scala/cats/data/IorT.scala @@ -78,7 +78,7 @@ final case class IorT[F[_], A, B](value: F[Ior[A, B]]) { * res0: Try[Int] = Failure(java.lang.RuntimeException: ERROR!) * }}} */ - def getOrRaise[E](e: => E)(implicit F: MonadError[F, _ >: E]): F[B] = + def getOrRaise[E](e: => E)(implicit F: MonadError[F, ? >: E]): F[B] = getOrElseF(F.raiseError(e)) def valueOr[BB >: B](f: A => BB)(implicit F: Functor[F], BB: Semigroup[BB]): F[BB] = F.map(value)(_.valueOr(f)) diff --git a/core/src/main/scala/cats/data/Kleisli.scala b/core/src/main/scala/cats/data/Kleisli.scala index 48a7ab34d1..ce34adc147 100644 --- a/core/src/main/scala/cats/data/Kleisli.scala +++ b/core/src/main/scala/cats/data/Kleisli.scala @@ -76,7 +76,7 @@ final case class Kleisli[F[_], -A, B](run: A => F[B]) { self => } def flatMapF[C](f: B => F[C])(implicit F: FlatMap[F]): Kleisli[F, A, C] = run match { - case run: StrictConstFunction1[_] => Kleisli(run.andThen(F.flatMap(_: F[B])(f))) + case run: StrictConstFunction1[?] => Kleisli(run.andThen(F.flatMap(_: F[B])(f))) case _ => Kleisli.shift(a => F.flatMap(run(a))(f)) } diff --git a/core/src/main/scala/cats/data/OptionT.scala b/core/src/main/scala/cats/data/OptionT.scala index 1104c65fb3..d16a09ba94 100644 --- a/core/src/main/scala/cats/data/OptionT.scala +++ b/core/src/main/scala/cats/data/OptionT.scala @@ -315,7 +315,7 @@ final case class OptionT[F[_], A](value: F[Option[A]]) { * res0: Try[Int] = Failure(java.lang.RuntimeException: ERROR!) * }}} */ - def getOrRaise[E](e: => E)(implicit F: MonadError[F, _ >: E]): F[A] = + def getOrRaise[E](e: => E)(implicit F: MonadError[F, ? >: E]): F[A] = getOrElseF(F.raiseError(e)) /** diff --git a/core/src/main/scala/cats/instances/try.scala b/core/src/main/scala/cats/instances/try.scala index 6eb96ca9cf..49c39cd74a 100644 --- a/core/src/main/scala/cats/instances/try.scala +++ b/core/src/main/scala/cats/instances/try.scala @@ -37,20 +37,20 @@ trait TryInstances extends TryInstances1 { override def product[A, B](ta: Try[A], tb: Try[B]): Try[(A, B)] = (ta, tb) match { case (Success(a), Success(b)) => Success((a, b)) - case (f: Failure[_], _) => castFailure[(A, B)](f) - case (_, f: Failure[_]) => castFailure[(A, B)](f) + case (f: Failure[?], _) => castFailure[(A, B)](f) + case (_, f: Failure[?]) => castFailure[(A, B)](f) } override def map2[A, B, Z](ta: Try[A], tb: Try[B])(f: (A, B) => Z): Try[Z] = (ta, tb) match { case (Success(a), Success(b)) => Try(f(a, b)) - case (f: Failure[_], _) => castFailure[Z](f) - case (_, f: Failure[_]) => castFailure[Z](f) + case (f: Failure[?], _) => castFailure[Z](f) + case (_, f: Failure[?]) => castFailure[Z](f) } override def map2Eval[A, B, Z](ta: Try[A], tb: Eval[Try[B]])(f: (A, B) => Z): Eval[Try[Z]] = ta match { - case f: Failure[_] => Now(castFailure[Z](f)) + case f: Failure[?] => Now(castFailure[Z](f)) case Success(a) => tb.map(_.map(f(a, _))) } @@ -71,7 +71,7 @@ trait TryInstances extends TryInstances1 { def traverse[G[_], A, B](fa: Try[A])(f: A => G[B])(implicit G: Applicative[G]): G[Try[B]] = fa match { case Success(a) => G.map(f(a))(Success(_)) - case f: Failure[_] => G.pure(castFailure[B](f)) + case f: Failure[?] => G.pure(castFailure[B](f)) } override def mapAccumulate[S, A, B](init: S, fa: Try[A])(f: (S, A) => (S, B)): (S, Try[B]) = { @@ -79,13 +79,13 @@ trait TryInstances extends TryInstances1 { case Success(a) => val (snext, b) = f(init, a) (snext, Success(b)) - case f: Failure[_] => (init, castFailure[B](f)) + case f: Failure[?] => (init, castFailure[B](f)) } } @tailrec final def tailRecM[B, C](b: B)(f: B => Try[Either[B, C]]): Try[C] = f(b) match { - case f: Failure[_] => castFailure[C](f) + case f: Failure[?] => castFailure[C](f) case Success(Left(b1)) => tailRecM(b1)(f) case Success(Right(c)) => Success(c) } @@ -200,7 +200,7 @@ private[instances] object TryInstances { * A `Failure` can be statically typed as `Try[A]` for all `A`, because it * does not actually contain an `A` value (as `Success[A]` does). */ - @inline final def castFailure[A](f: Failure[_]): Try[A] = f.asInstanceOf[Try[A]] + @inline final def castFailure[A](f: Failure[?]): Try[A] = f.asInstanceOf[Try[A]] } sealed private[instances] trait TryInstances1 extends TryInstances2 { diff --git a/core/src/main/scala/cats/syntax/applicativeError.scala b/core/src/main/scala/cats/syntax/applicativeError.scala index 402c9f719a..352658fc8e 100644 --- a/core/src/main/scala/cats/syntax/applicativeError.scala +++ b/core/src/main/scala/cats/syntax/applicativeError.scala @@ -63,7 +63,7 @@ final private[syntax] class ApplicativeErrorExtensionOps[F[_], E](F: Applicative } final class ApplicativeErrorIdOps[E](private val e: E) extends AnyVal { - def raiseError[F[_], A](implicit F: ApplicativeError[F, _ >: E]): F[A] = + def raiseError[F[_], A](implicit F: ApplicativeError[F, ? >: E]): F[A] = F.raiseError(e) } diff --git a/core/src/main/scala/cats/syntax/either.scala b/core/src/main/scala/cats/syntax/either.scala index 2a39e65963..a4361545c0 100644 --- a/core/src/main/scala/cats/syntax/either.scala +++ b/core/src/main/scala/cats/syntax/either.scala @@ -352,7 +352,7 @@ final class EitherOps[A, B](private val eab: Either[A, B]) extends AnyVal { * res0: cats.data.EitherT[Option, CharSequence, Int] = EitherT(Some(Right(3))) * }}} */ - def liftTo[F[_]](implicit F: ApplicativeError[F, _ >: A]): F[B] = F.fromEither(eab) + def liftTo[F[_]](implicit F: ApplicativeError[F, ? >: A]): F[B] = F.fromEither(eab) } final class EitherObjectOps(private val either: Either.type) extends AnyVal { diff --git a/core/src/main/scala/cats/syntax/monadError.scala b/core/src/main/scala/cats/syntax/monadError.scala index a3a858995a..5b13b52059 100644 --- a/core/src/main/scala/cats/syntax/monadError.scala +++ b/core/src/main/scala/cats/syntax/monadError.scala @@ -28,7 +28,7 @@ trait MonadErrorSyntax { implicit final def catsSyntaxMonadErrorRethrow[F[_], E, A]( fea: F[Either[E, A]] - )(implicit F: MonadError[F, _ >: E]): MonadErrorRethrowOps[F, E, A] = + )(implicit F: MonadError[F, ? >: E]): MonadErrorRethrowOps[F, E, A] = new MonadErrorRethrowOps(fea) } @@ -59,7 +59,7 @@ final class MonadErrorOps[F[_], E, A](private val fa: F[A]) extends AnyVal { } final class MonadErrorRethrowOps[F[_], E, A](private val fea: F[Either[E, A]]) extends AnyVal { - def rethrow(implicit F: MonadError[F, _ >: E]): F[A] = + def rethrow(implicit F: MonadError[F, ? >: E]): F[A] = F.flatMap(fea)( _.fold(F.raiseError, F.pure) ) // dup from the type class impl, due to https://github.com/scala/bug/issues/11562. Once fixed should be able to replace with `F.rethrow(fea)` diff --git a/core/src/main/scala/cats/syntax/option.scala b/core/src/main/scala/cats/syntax/option.scala index d62073cdf6..16cc8a3270 100644 --- a/core/src/main/scala/cats/syntax/option.scala +++ b/core/src/main/scala/cats/syntax/option.scala @@ -391,7 +391,7 @@ final class OptionOps[A](private val oa: Option[A]) extends AnyVal { object OptionOps { final class LiftToPartiallyApplied[F[_], A](oa: Option[A]) { - def apply[E](ifEmpty: => E)(implicit F: ApplicativeError[F, _ >: E]): F[A] = + def apply[E](ifEmpty: => E)(implicit F: ApplicativeError[F, ? >: E]): F[A] = ApplicativeError.liftFromOption(oa, ifEmpty) } } diff --git a/core/src/main/scala/cats/syntax/validated.scala b/core/src/main/scala/cats/syntax/validated.scala index 68b386b8e1..68cc1bdda9 100644 --- a/core/src/main/scala/cats/syntax/validated.scala +++ b/core/src/main/scala/cats/syntax/validated.scala @@ -41,7 +41,7 @@ trait ValidatedExtensionSyntax { } final class ValidatedExtension[E, A](private val self: Validated[E, A]) extends AnyVal { - def liftTo[F[_]](implicit F: ApplicativeError[F, _ >: E]): F[A] = + def liftTo[F[_]](implicit F: ApplicativeError[F, ? >: E]): F[A] = F.fromValidated(self) } diff --git a/free/src/main/scala/cats/free/FreeApplicative.scala b/free/src/main/scala/cats/free/FreeApplicative.scala index fdb0f9d1cf..93e22a8304 100644 --- a/free/src/main/scala/cats/free/FreeApplicative.scala +++ b/free/src/main/scala/cats/free/FreeApplicative.scala @@ -80,7 +80,7 @@ sealed abstract class FreeApplicative[F[_], A] extends Product with Serializable argsFLength -= 1 // rip off every `Ap` in `argF` in function position - if (argF.isInstanceOf[Ap[F, _, _]]) { + if (argF.isInstanceOf[Ap[F, ?, ?]]) { val lengthInitial = argsFLength // reassociate the functions into a single fn, // and move the arguments into argsF @@ -89,7 +89,7 @@ sealed abstract class FreeApplicative[F[_], A] extends Product with Serializable argsF ::= ap.fp argsFLength += 1 argF = ap.fn.asInstanceOf[FA[F, Any]] - argF.isInstanceOf[Ap[F, _, _]] + argF.isInstanceOf[Ap[F, ?, ?]] }) () // consecutive `ap` calls have been queued as operations; // argF is no longer an `Ap` node, so the entire topmost left-associated diff --git a/kernel/src/main/scala/cats/kernel/Semigroup.scala b/kernel/src/main/scala/cats/kernel/Semigroup.scala index 75291f54ff..e861f481fe 100644 --- a/kernel/src/main/scala/cats/kernel/Semigroup.scala +++ b/kernel/src/main/scala/cats/kernel/Semigroup.scala @@ -140,10 +140,10 @@ abstract class SemigroupFunctions[S[T] <: Semigroup[T]] { } def isCommutative[A](implicit ev: S[A]): Boolean = - ev.isInstanceOf[CommutativeSemigroup[_]] + ev.isInstanceOf[CommutativeSemigroup[?]] def isIdempotent[A](implicit ev: S[A]): Boolean = - ev.isInstanceOf[Band[_]] + ev.isInstanceOf[Band[?]] def combineN[@sp(Int, Long, Float, Double) A](a: A, n: Int)(implicit ev: S[A]): A = ev.combineN(a, n) diff --git a/tests/shared/src/test/scala/cats/tests/EitherSuite.scala b/tests/shared/src/test/scala/cats/tests/EitherSuite.scala index 851eec7901..eca7b226e7 100644 --- a/tests/shared/src/test/scala/cats/tests/EitherSuite.scala +++ b/tests/shared/src/test/scala/cats/tests/EitherSuite.scala @@ -108,9 +108,9 @@ class EitherSuite extends CatsSuite { test("implicit instances resolve specifically") { val eq = cats.kernel.instances.either.catsStdEqForEither[Int, String] - assert(!eq.isInstanceOf[PartialOrder[_]]) - assert(!eq.isInstanceOf[Order[_]]) - assert(!partialOrder.isInstanceOf[Order[_]]) + assert(!eq.isInstanceOf[PartialOrder[?]]) + assert(!eq.isInstanceOf[Order[?]]) + assert(!partialOrder.isInstanceOf[Order[?]]) } test("show isn't empty") {