Skip to content

Commit

Permalink
Merge pull request #4698 from typelevel/update/scalafmt-core-3.8.4
Browse files Browse the repository at this point in the history
Update scalafmt-core to 3.8.4
  • Loading branch information
satorg authored Jan 13, 2025
2 parents 304ab00 + 9ff3478 commit 5a1d395
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ f025b0198d55d7f5c09ee976eec9e274d8dd0309

# Scala Steward: Reformat with scalafmt 3.5.9
b4d207e9fa9f1463f0827fe20101e7901fecf820

# Scala Steward: Reformat with scalafmt 3.8.4
42490f49d2a62289c8ca0a57357f323982eeb93b
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=3.8.2
version=3.8.4
align.openParenCallSite = true
align.openParenDefnSite = true
maxColumn = 120
Expand Down
28 changes: 14 additions & 14 deletions core/src/main/scala/cats/evidence/As.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ sealed abstract class As[-A, +B] extends Serializable {
*/
def substitute[F[-_]](p: F[B]): F[A]

@inline final def andThen[C](that: (B As C)): (A As C) = As.compose(that, this)
@inline final def andThen[C](that: B As C): A As C = As.compose(that, this)

@inline final def compose[C](that: (C As A)): (C As B) = As.compose(this, that)
@inline final def compose[C](that: C As A): C As B = As.compose(this, that)

@inline final def coerce(a: A): B = As.witness(this)(a)

Expand All @@ -73,9 +73,9 @@ sealed abstract class AsInstances {
* Subtyping forms a category
*/
implicit val liskov: Category[As] = new Category[As] {
def id[A]: (A As A) = refl[A]
def id[A]: A As A = refl[A]

def compose[A, B, C](bc: B As C, ab: A As B): (A As C) = bc.compose(ab)
def compose[A, B, C](bc: B As C, ab: A As B): A As C = bc.compose(ab)
}
}

Expand All @@ -92,7 +92,7 @@ object As extends AsInstances with AsSupport {
/**
* Subtyping is reflexive
*/
implicit def refl[A]: (A As A) =
implicit def refl[A]: A As A =
reflAny.asInstanceOf[A As A]

/**
Expand All @@ -114,7 +114,7 @@ object As extends AsInstances with AsSupport {
/**
* reify a subtype relationship as a Liskov relationship
*/
@inline def reify[A, B >: A]: (A As B) = refl
@inline def reify[A, B >: A]: A As B = refl

/**
* It can be convenient to convert a <:< value into a `<~<` value.
Expand All @@ -127,7 +127,7 @@ object As extends AsInstances with AsSupport {
/**
* We can lift subtyping into any covariant type constructor
*/
def co[T[+_], A, A2](a: A As A2): (T[A] As T[A2]) = {
def co[T[+_], A, A2](a: A As A2): T[A] As T[A2] = {
type L[-α] = T[α] As T[A2]
a.substitute[L](refl)
}
Expand Down Expand Up @@ -179,7 +179,7 @@ object As extends AsInstances with AsSupport {
def lift2[T[+_, +_], A, A2, B, B2](
a: A As A2,
b: B As B2
): (T[A, B] As T[A2, B2]) = {
): T[A, B] As T[A2, B2] = {
type a[-X] = T[X, B2] As T[A2, B2]
type b[-X] = T[A, X] As T[A2, B2]
b.substitute[b](a.substitute[a](refl))
Expand All @@ -192,7 +192,7 @@ object As extends AsInstances with AsSupport {
* Given that F has the shape: F[-_], we show that:
* (A As B) implies (F[B] As F[A])
*/
def contra[T[-_], A, B](a: A As B): (T[B] As T[A]) = {
def contra[T[-_], A, B](a: A As B): T[B] As T[A] = {
type L[-α] = T[B] As T[α]
a.substitute[L](refl)
}
Expand All @@ -201,27 +201,27 @@ object As extends AsInstances with AsSupport {
// parameter. Here we provide the proof for what we expect to be the
// most common shapes.

def contra1_2[T[-_, _], Z, A, B](a: A As Z): (T[Z, B] As T[A, B]) = {
def contra1_2[T[-_, _], Z, A, B](a: A As Z): T[Z, B] As T[A, B] = {
type L[-α] = T[Z, B] As T[α, B]
a.substitute[L](refl)
}

def contra2_2[T[_, -_], Z, A, B](a: B As Z): (T[A, Z] As T[A, B]) = {
def contra2_2[T[_, -_], Z, A, B](a: B As Z): T[A, Z] As T[A, B] = {
type L[-α] = T[A, Z] As T[A, α]
a.substitute[L](refl)
}

def contra1_3[T[-_, _, _], Z, A, B, C](a: A As Z): (T[Z, B, C] As T[A, B, C]) = {
def contra1_3[T[-_, _, _], Z, A, B, C](a: A As Z): T[Z, B, C] As T[A, B, C] = {
type L[-α] = T[Z, B, C] As T[α, B, C]
a.substitute[L](refl)
}

def contra2_3[T[_, -_, _], Z, A, B, C](a: B As Z): (T[A, Z, C] As T[A, B, C]) = {
def contra2_3[T[_, -_, _], Z, A, B, C](a: B As Z): T[A, Z, C] As T[A, B, C] = {
type L[-α] = T[A, Z, C] As T[A, α, C]
a.substitute[L](refl)
}

def contra3_3[T[_, _, -_], Z, A, B, C](a: C As Z): (T[A, B, Z] As T[A, B, C]) = {
def contra3_3[T[_, _, -_], Z, A, B, C](a: C As Z): T[A, B, Z] As T[A, B, C] = {
type L[-α] = T[A, B, Z] As T[A, B, α]
a.substitute[L](refl)
}
Expand Down
14 changes: 7 additions & 7 deletions tests/shared/src/test/scala/cats/tests/AsSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ class AsSuite extends CatsSuite {
test("we can lift subtyping to covariant type constructors") {
val cAsA: Bottom As Top = implicitly
val co: List[Bottom] As List[Top] = As.co(cAsA)
val co2: ((Bottom, String) As (Top, String)) = As.co2(cAsA)
val co2_2: ((String, Bottom) As (String, Top)) = As.co2_2(cAsA)
val co3: ((Bottom, Unit, Unit) As (Top, Unit, Unit)) = As.co3(cAsA)
val co3_2: ((Unit, Bottom, Unit) As (Unit, Top, Unit)) = As.co3_2(cAsA)
val co3_3: ((Unit, Unit, Bottom) As (Unit, Unit, Top)) = As.co3_3(cAsA)
val lift2: ((Bottom, String) As (Top, Any)) = As.lift2(cAsA, implicitly)
val co2: (Bottom, String) As (Top, String) = As.co2(cAsA)
val co2_2: (String, Bottom) As (String, Top) = As.co2_2(cAsA)
val co3: (Bottom, Unit, Unit) As (Top, Unit, Unit) = As.co3(cAsA)
val co3_2: (Unit, Bottom, Unit) As (Unit, Top, Unit) = As.co3_2(cAsA)
val co3_3: (Unit, Unit, Bottom) As (Unit, Unit, Top) = As.co3_3(cAsA)
val lift2: (Bottom, String) As (Top, Any) = As.lift2(cAsA, implicitly)
}

test("we can lift subtyping to contravariant type constructors") {
Expand All @@ -119,7 +119,7 @@ class AsSuite extends CatsSuite {
type EatF23[B, -A, C] = A => (B, C)
type EatF33[B, C, -A] = A => (B, C)

val cAsA: (Bottom As Top) = implicitly
val cAsA: Bottom As Top = implicitly
val contra: Eat[Top] As Eat[Bottom] = As.contra(cAsA)
val contra1_2: EatF[Top, Unit] As EatF[Bottom, Unit] = As.contra1_2(cAsA)
val contra2_2: Eatꟻ[Unit, Top] As Eatꟻ[Unit, Bottom] = As.contra2_2(cAsA)
Expand Down
10 changes: 6 additions & 4 deletions tests/shared/src/test/scala/cats/tests/IndexedStateTSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,9 @@ class IndexedStateTSuite extends CatsSuite {
checkAll("IndexedStateT[ListWrapper, MiniInt, Int, *]",
FunctorFilterTests[IndexedStateT[ListWrapper, MiniInt, Int, *]].functorFilter[Int, Int, Int]
)
checkAll("FunctorFilter[IndexedStateT[ListWrapper, MiniInt, Int, *]]",
SerializableTests.serializable(FunctorFilter[IndexedStateT[ListWrapper, MiniInt, Int, *]])
checkAll(
"FunctorFilter[IndexedStateT[ListWrapper, MiniInt, Int, *]]",
SerializableTests.serializable(FunctorFilter[IndexedStateT[ListWrapper, MiniInt, Int, *]])
)

FunctorFilter[IndexedStateT[ListWrapper, String, Int, *]]
Expand All @@ -438,8 +439,9 @@ class IndexedStateTSuite extends CatsSuite {
implicit val F: Monad[ListWrapper] = ListWrapper.monad
implicit val FS: Bifunctor[IndexedStateT[ListWrapper, Int, *, *]] = IndexedStateT.catsDataBifunctorForIndexedStateT

checkAll("IndexedStateT[ListWrapper, MiniInt, String, Int]",
BifunctorTests[IndexedStateT[ListWrapper, MiniInt, *, *]].bifunctor[String, String, String, Int, Int, Int]
checkAll(
"IndexedStateT[ListWrapper, MiniInt, String, Int]",
BifunctorTests[IndexedStateT[ListWrapper, MiniInt, *, *]].bifunctor[String, String, String, Int, Int, Int]
)
checkAll("Bifunctor[IndexedStateT[ListWrapper, Int, *, *]]",
SerializableTests.serializable(Bifunctor[IndexedStateT[ListWrapper, Int, *, *]])
Expand Down
5 changes: 3 additions & 2 deletions tests/shared/src/test/scala/cats/tests/NestedSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,9 @@ class NestedSuite extends CatsSuite {
checkAll("Nested[NonEmptyList, OneAnd[ListWrapper, *], *]",
ReducibleTests[Nested[NonEmptyList, OneAnd[ListWrapper, *], *]].reducible[Option, Int, Int]
)
checkAll("Reducible[Nested[NonEmptyList, OneAnd[ListWrapper, *], *]]",
SerializableTests.serializable(Reducible[Nested[NonEmptyList, OneAnd[ListWrapper, *], *]])
checkAll(
"Reducible[Nested[NonEmptyList, OneAnd[ListWrapper, *], *]]",
SerializableTests.serializable(Reducible[Nested[NonEmptyList, OneAnd[ListWrapper, *], *]])
)
}

Expand Down

0 comments on commit 5a1d395

Please sign in to comment.