diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0a3d5021c..325176e42 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - scala: [2.12.17, 2.13.10] + scala: [2.12.19, 2.13.11] java: [adopt@1.8] platform: [jvm, js, native] runs-on: ${{ matrix.os }} @@ -75,7 +75,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - scala: [2.13.10] + scala: [2.13.11] java: [adopt@1.8] runs-on: ${{ matrix.os }} steps: diff --git a/build.sbt b/build.sbt index 604d9a387..a8e2d2799 100644 --- a/build.sbt +++ b/build.sbt @@ -1,8 +1,8 @@ -import com.typesafe.sbt.SbtGit.GitKeys._ +import com.github.sbt.git.SbtGit.GitKeys.* import sbtcrossproject.CrossProject -val Scala212 = "2.12.17" -val Scala213 = "2.13.10" +val Scala212 = "2.12.19" +val Scala213 = "2.13.11" commonSettings noPublishSettings @@ -59,32 +59,26 @@ addCommandAlias("runAll", ";examplesJVM/runAll") def scalacOptionsAll(pluginJar: File) = List( "-feature", - "-language:higherKinds,implicitConversions", - "-Xfatal-warnings", "-deprecation", "-unchecked", + "-language:higherKinds,implicitConversions", + "-Xfatal-warnings", + "-Wconf:cat=other-implicit-type:s", s"-Xplugin:${pluginJar.getAbsolutePath}", s"-Jdummy=${pluginJar.lastModified}" ) -val scalacOptions212 = Seq( - "-Xlint:-adapted-args,-delayedinit-select,-nullary-unit,-package-object-classes,-type-parameter-shadow,_", - "-Ywarn-unused:-implicits" -) - -val scalacOptions213 = Seq( - "-Xlint:-adapted-args,-delayedinit-select,-nullary-unit,-package-object-classes,-type-parameter-shadow,-byname-implicit,_", - "-Ywarn-unused:-implicits" -) - lazy val commonSettings = crossVersionSharedSources ++ Seq( resolvers ++= Resolver.sonatypeOssRepos("releases"), resolvers ++= Resolver.sonatypeOssRepos("snapshots"), incOptions := incOptions.value.withLogRecompileOnMacro(false), scalacOptions := scalacOptionsAll((plugin / Compile / packageBin).value), - Compile / compile / scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match { - case Some((2, 12)) => scalacOptions212 - case Some((2, 13)) => scalacOptions213 + Compile / compile / scalacOptions ++= Seq( + "-Ywarn-unused:-implicits", + "-Xlint:-adapted-args,-delayedinit-select,-nullary-unit,-package-object-classes,-type-parameter-shadow,_" + ), + Compile / compile / scalacOptions ++= (scalaBinaryVersion.value match { + case "2.13" => Seq("-Xlint:-byname-implicit") case _ => Nil }), Compile / console / scalacOptions -= "-Xfatal-warnings", @@ -184,7 +178,7 @@ lazy val examples = crossProject(JSPlatform, JVMPlatform, NativePlatform) .configureCross(configureJUnit) .dependsOn(core) .settings(moduleName := "examples") - .settings(libraryDependencies += "org.scala-lang.modules" %%% "scala-parser-combinators" % "2.2.0") + .settings(libraryDependencies += "org.scala-lang.modules" %%% "scala-parser-combinators" % "2.3.0") .settings(runAllIn(Compile)) .settings(commonSettings) .settings(noPublishSettings) @@ -194,7 +188,7 @@ lazy val examplesJVM = examples.jvm lazy val examplesJS = examples.js lazy val examplesNative = examples.native -lazy val crossVersionSharedSources: Seq[Setting[_]] = +lazy val crossVersionSharedSources: Seq[Setting[?]] = Seq(Compile, Test).map { sc => (sc / unmanagedSourceDirectories) ++= { (sc / unmanagedSourceDirectories).value.flatMap { dir: File => @@ -211,10 +205,10 @@ lazy val publishSettings = Seq( Test / publishArtifact := false, pomIncludeRepository := (_ => false), homepage := Some(url("https://github.com/milessabin/shapeless")), - licenses := Seq("Apache 2" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")), + licenses := Seq("Apache 2" -> url("https://www.apache.org/licenses/LICENSE-2.0.txt")), scmInfo := Some(ScmInfo(url("https://github.com/milessabin/shapeless"), "scm:git:git@github.com:milessabin/shapeless.git")), developers := List( - Developer("milessabin", "Miles Sabin", "", url("http://milessabin.com/blog")), + Developer("milessabin", "Miles Sabin", "", url("https://milessabin.com/blog")), Developer("joroKr21", "Georgi Krastev", "joro.kr.21@gmail.com", url("https://twitter.com/Joro_Kr")) ) ) diff --git a/core/shared/src/main/scala/shapeless/conversions.scala b/core/shared/src/main/scala/shapeless/conversions.scala index 71f299348..14f4c2e07 100644 --- a/core/shared/src/main/scala/shapeless/conversions.scala +++ b/core/shared/src/main/scala/shapeless/conversions.scala @@ -22,12 +22,12 @@ import ops.hlist.Tupler * Higher ranked function which converts `HLists` to tuples. */ object tupled extends Poly1 { - implicit def caseHList[L <: HList](implicit tupler: Tupler[L]) = at[L](tupler(_)) + implicit def caseHList[L <: HList](implicit tupler: Tupler[L]): Case.Aux[L, tupler.Out] = at[L](tupler(_)) } /** * Higher ranked function which converts products to `HLists`. */ object productElements extends Poly1 { - implicit def caseProduct[P](implicit gen: Generic[P]) = at[P](p => gen.to(p)) + implicit def caseProduct[P](implicit gen: Generic[P]): Case.Aux[P, gen.Repr] = at[P](p => gen.to(p)) } diff --git a/core/shared/src/main/scala/shapeless/coproduct.scala b/core/shared/src/main/scala/shapeless/coproduct.scala index 94929dd3e..f5d9d06f6 100644 --- a/core/shared/src/main/scala/shapeless/coproduct.scala +++ b/core/shared/src/main/scala/shapeless/coproduct.scala @@ -130,7 +130,7 @@ object Coproduct extends Dynamic { def apply[C <: Coproduct] = new MkCoproduct[C] - implicit def cpOps[C <: Coproduct](c: C) = new CoproductOps(c) + implicit def cpOps[C <: Coproduct](c: C): CoproductOps[C] = new CoproductOps(c) def unsafeMkCoproduct(length: Int, value: Any) = (0 until length).foldLeft[Coproduct](Inl(value))((accum, _) => Inr(accum)) diff --git a/core/shared/src/main/scala/shapeless/hmap.scala b/core/shared/src/main/scala/shapeless/hmap.scala index cdba5c2b3..b4b192930 100644 --- a/core/shared/src/main/scala/shapeless/hmap.scala +++ b/core/shared/src/main/scala/shapeless/hmap.scala @@ -36,7 +36,7 @@ class HMap[R[_, _]](underlying : Map[Any, Any] = Map.empty) extends Poly1 { def +[K, V](kv : (K, V))(implicit ev : R[K, V]) : HMap[R] = new HMap[R](underlying+kv) def -[K](k : K) : HMap[R] = new HMap[R](underlying-k) - implicit def caseRel[K, V](implicit ev : R[K, V]) = Case1[this.type, K, V](get(_).get) + implicit def caseRel[K, V](implicit ev : R[K, V]): Case1.Aux[this.type, K, V] = Case1[this.type, K, V](get(_).get) } object HMap { diff --git a/core/shared/src/main/scala/shapeless/lenses.scala b/core/shared/src/main/scala/shapeless/lenses.scala index 4427de7b2..e805b589c 100644 --- a/core/shared/src/main/scala/shapeless/lenses.scala +++ b/core/shared/src/main/scala/shapeless/lenses.scala @@ -162,7 +162,7 @@ object OpticDefns { def apply[C] = id[C] object compose extends Poly2 { - implicit def default[A, B, C] = at[Lens[B, C], Lens[A, B]](_ compose _) + implicit def default[A, B, C]: Case.Aux[Lens[B, C], Lens[A, B], Lens[A, C]] = at[Lens[B, C], Lens[A, B]](_ compose _) } class RootLens[C] extends Lens[C, C] { @@ -248,10 +248,10 @@ object MkFieldLens { implicit def mkFieldLens[A, K, R <: HList, B] (implicit mkGen: MkLabelledGenericLens.Aux[A, R], - mkLens: MkRecordSelectLens[R, K]): Aux[A, K, mkLens.Elem] = + mkLens: MkRecordSelectLens.Aux[R, K, B]): Aux[A, K, B] = new MkFieldLens[A, K] { - type Elem = mkLens.Elem - def apply(): Lens[A, mkLens.Elem] = mkLens() compose mkGen() + type Elem = B + def apply(): Lens[A, B] = mkLens() compose mkGen() } } diff --git a/core/shared/src/main/scala/shapeless/ops/hlists.scala b/core/shared/src/main/scala/shapeless/ops/hlists.scala index 623f8c47b..6c918bfa1 100644 --- a/core/shared/src/main/scala/shapeless/ops/hlists.scala +++ b/core/shared/src/main/scala/shapeless/ops/hlists.scala @@ -121,35 +121,35 @@ object hlist { object NatTRel { def apply[L1 <: HList, F1[_], L2 <: HList, F2[_]](implicit natTRel: NatTRel[L1, F1, L2, F2]) = natTRel - implicit def hnilNatTRel1[F1[_], F2[_]] = new NatTRel[HNil, F1, HNil, F2] { + implicit def hnilNatTRel1[F1[_], F2[_]]: NatTRel[HNil, F1, HNil, F2] = new NatTRel[HNil, F1, HNil, F2] { def map(f: F1 ~> F2, fa: HNil): HNil = HNil } - implicit def hnilNatTRel2[F1[_], H2] = new NatTRel[HNil, F1, HNil, Const[H2]#λ] { + implicit def hnilNatTRel2[F1[_], H2]: NatTRel[HNil, F1, HNil, Const[H2]#λ] = new NatTRel[HNil, F1, HNil, Const[H2]#λ] { def map(f: F1 ~> Const[H2]#λ, fa: HNil): HNil = HNil } - implicit def hlistNatTRel1[H, F1[_], F2[_], T1 <: HList, T2 <: HList](implicit nt : NatTRel[T1, F1, T2, F2]) = + implicit def hlistNatTRel1[H, F1[_], F2[_], T1 <: HList, T2 <: HList](implicit nt : NatTRel[T1, F1, T2, F2]): NatTRel[F1[H] :: T1, F1, F2[H] :: T2, F2] = new NatTRel[F1[H] :: T1, F1, F2[H] :: T2, F2] { def map(f: F1 ~> F2, fa: F1[H] :: T1): F2[H] :: T2 = f(fa.head) :: nt.map(f, fa.tail) } - implicit def hlistNatTRel2[H, F2[_], T1 <: HList, T2 <: HList](implicit nt : NatTRel[T1, Id, T2, F2]) = + implicit def hlistNatTRel2[H, F2[_], T1 <: HList, T2 <: HList](implicit nt : NatTRel[T1, Id, T2, F2]): NatTRel[H :: T1, Id, F2[H] :: T2, F2] = new NatTRel[H :: T1, Id, F2[H] :: T2, F2] { def map(f: Id ~> F2, fa: H :: T1): F2[H] :: T2 = f(fa.head) :: nt.map(f, fa.tail) } - implicit def hlistNatTRel3[H, F1[_], T1 <: HList, T2 <: HList](implicit nt : NatTRel[T1, F1, T2, Id]) = + implicit def hlistNatTRel3[H, F1[_], T1 <: HList, T2 <: HList](implicit nt : NatTRel[T1, F1, T2, Id]): NatTRel[F1[H] :: T1, F1, H :: T2, Id] = new NatTRel[F1[H] :: T1, F1, H :: T2, Id] { def map(f: F1 ~> Id, fa: F1[H] :: T1): H :: T2 = f(fa.head) :: nt.map(f, fa.tail) } - implicit def hlistNatTRel4[H1, F1[_], T1 <: HList, H2, T2 <: HList](implicit nt : NatTRel[T1, F1, T2, Const[H2]#λ]) = + implicit def hlistNatTRel4[H1, F1[_], T1 <: HList, H2, T2 <: HList](implicit nt : NatTRel[T1, F1, T2, Const[H2]#λ]): NatTRel[F1[H1] :: T1, F1, H2 :: T2, Const[H2]#λ] = new NatTRel[F1[H1] :: T1, F1, H2 :: T2, Const[H2]#λ] { def map(f: F1 ~> Const[H2]#λ, fa: F1[H1] :: T1): H2 :: T2 = f(fa.head) :: nt.map(f, fa.tail) } - implicit def hlistNatTRel5[H1, T1 <: HList, H2, T2 <: HList](implicit nt : NatTRel[T1, Id, T2, Const[H2]#λ]) = + implicit def hlistNatTRel5[H1, T1 <: HList, H2, T2 <: HList](implicit nt : NatTRel[T1, Id, T2, Const[H2]#λ]): NatTRel[H1 :: T1, Id, H2 :: T2, Const[H2]#λ] = new NatTRel[H1 :: T1, Id, H2 :: T2, Const[H2]#λ] { def map(f: Id ~> Const[H2]#λ, fa: H1 :: T1): H2 :: T2 = f(fa.head) :: nt.map(f, fa.tail) } @@ -214,12 +214,12 @@ object hlist { type Aux[L <: HList, Out0 <: HKernel] = HKernelAux[L] { type Out = Out0 } - implicit def mkHNilHKernel = new HKernelAux[HNil] { + implicit def mkHNilHKernel: Aux[HNil, HNilHKernel] = new HKernelAux[HNil] { type Out = HNilHKernel def apply() = HNilHKernel } - implicit def mkHListHKernel[H, T <: HList, CtOut <: HKernel](implicit ct: HKernelAux.Aux[T, CtOut]) = new HKernelAux[H :: T] { + implicit def mkHListHKernel[H, T <: HList, CtOut <: HKernel](implicit ct: HKernelAux.Aux[T, CtOut]): Aux[H :: T, HConsHKernel[H, CtOut]] = new HKernelAux[H :: T] { type Out = HConsHKernel[H, CtOut] def apply() = HConsHKernel[H, CtOut](ct()) } @@ -2749,7 +2749,7 @@ object hlist { type Aux[L <: HList, V, P <: Poly, Out0 <: HList] = RightScanner0[L, V, P] { type Out = Out0 } } - implicit def hlistRightScanner0[H, H0, T <: HList, P <: Poly, C2Result](implicit ev: Case2.Aux[P, H0, H, C2Result]) = + implicit def hlistRightScanner0[H, H0, T <: HList, P <: Poly, C2Result](implicit ev: Case2.Aux[P, H0, H, C2Result]): RightScanner0.Aux[H :: T, H0, P, C2Result :: H :: T] = new RightScanner0[H :: T, H0, P]{ type Out = C2Result :: H :: T @@ -2854,7 +2854,7 @@ object hlist { } implicit def hlistPatch2[M <: Nat, L <: HList, In <: HList, OutL <: HList, OutP <: HList] - (implicit drop: Drop.Aux[L, M, OutL], prepend: Prepend.Aux[In, OutL, OutP]) = + (implicit drop: Drop.Aux[L, M, OutL], prepend: Prepend.Aux[In, OutL, OutP]): Patcher.Aux[_0, M, L, In, OutP] = new Patcher[_0, M, L, In]{ type Out = OutP @@ -3058,7 +3058,7 @@ object hlist { } trait LowPriorityCombinations { - implicit def combinationHNil[N <: Nat] = + implicit def combinationHNil[N <: Nat]: Combinations.Aux[N, HNil, HNil] = new Combinations[N, HNil] { type Out = HNil def apply(l: HNil): Out = HNil diff --git a/core/shared/src/main/scala/shapeless/ops/nat.scala b/core/shared/src/main/scala/shapeless/ops/nat.scala index 8b624fd8c..3f7191f46 100644 --- a/core/shared/src/main/scala/shapeless/ops/nat.scala +++ b/core/shared/src/main/scala/shapeless/ops/nat.scala @@ -140,14 +140,14 @@ object nat { object LT extends LT0 { def apply[A <: Nat, B <: Nat](implicit lt: A < B): LT[A, B] = lt - implicit def lt1[B <: Nat] = new <[_0, Succ[B]] {} - implicit def lt2[A <: Nat, B <: Nat](implicit lt : A < B) = new <[Succ[A], Succ[B]] {} + implicit def lt1[B <: Nat]: _0 < Succ[B] = new <[_0, Succ[B]] {} + implicit def lt2[A <: Nat, B <: Nat](implicit lt : A < B): Succ[A] < Succ[B] = new <[Succ[A], Succ[B]] {} } trait LT0 { type <[A <: Nat, B <: Nat] = LT[A, B] - implicit def lt3[A <: Nat] = new <[A, Succ[A]] {} + implicit def lt3[A <: Nat]: A < Succ[A] = new <[A, Succ[A]] {} } /** @@ -160,15 +160,15 @@ object nat { object LTEq extends LTEq0 { def apply[A <: Nat, B <: Nat](implicit lteq: A <= B): LTEq[A, B] = lteq - implicit def ltEq1[A <: Nat] = new <=[A, A] {} - implicit def ltEq2[A <: Nat] = new <=[A, Succ[A]] {} + implicit def ltEq1[A <: Nat]: A <= A = new <=[A, A] {} + implicit def ltEq2[A <: Nat]: A <= Succ[A] = new <=[A, Succ[A]] {} } trait LTEq0 { type <=[A <: Nat, B <: Nat] = LTEq[A, B] - implicit def ltEq3[B <: Nat] = new <=[_0, B] {} - implicit def ltEq4[A <: Nat, B <: Nat](implicit lteq : A <= B) = new <=[Succ[A], Succ[B]] {} + implicit def ltEq3[B <: Nat]: _0 <= B = new <=[_0, B] {} + implicit def ltEq4[A <: Nat, B <: Nat](implicit lteq : A <= B): Succ[A] <= Succ[B] = new <=[Succ[A], Succ[B]] {} } /** diff --git a/core/shared/src/main/scala/shapeless/ops/traversables.scala b/core/shared/src/main/scala/shapeless/ops/traversables.scala index 45babd7c0..e42e88f97 100644 --- a/core/shared/src/main/scala/shapeless/ops/traversables.scala +++ b/core/shared/src/main/scala/shapeless/ops/traversables.scala @@ -37,13 +37,13 @@ object traversable { import syntax.typeable._ - implicit def hnilFromTraversable[T] = new FromTraversable[HNil] { + implicit def hnilFromTraversable[T]: FromTraversable[HNil] = new FromTraversable[HNil] { def apply(l : Iterable[_]) = if(l.isEmpty) Some(HNil) else None } implicit def hlistFromTraversable[OutH, OutT <: HList] - (implicit flt : FromTraversable[OutT], oc : Typeable[OutH]) = new FromTraversable[OutH :: OutT] { + (implicit flt : FromTraversable[OutT], oc : Typeable[OutH]): FromTraversable[OutH :: OutT] = new FromTraversable[OutH :: OutT] { def apply(l : Iterable[_]) : Option[OutH :: OutT] = if(l.isEmpty) None else for(h <- l.head.cast[OutH]; t <- flt(l.tail)) yield h :: t diff --git a/core/shared/src/main/scala/shapeless/ops/tuples.scala b/core/shared/src/main/scala/shapeless/ops/tuples.scala index b0713f5ee..2315c9dc8 100644 --- a/core/shared/src/main/scala/shapeless/ops/tuples.scala +++ b/core/shared/src/main/scala/shapeless/ops/tuples.scala @@ -1243,7 +1243,7 @@ object tuple { (implicit gen: Generic.Aux[T, L], genIn: Generic.Aux[InT, InL], patch: hl.Patcher.Aux[N, M, L, InL, OutL], - tp: hl.Tupler[OutL]) = + tp: hl.Tupler[OutL]): Patcher[N, M, T, InT] { type Out = tp.Out } = new Patcher[N, M, T, InT]{ type Out = tp.Out diff --git a/core/shared/src/main/scala/shapeless/poly.scala b/core/shared/src/main/scala/shapeless/poly.scala index 5ece0159d..ba627fe9a 100644 --- a/core/shared/src/main/scala/shapeless/poly.scala +++ b/core/shared/src/main/scala/shapeless/poly.scala @@ -73,7 +73,7 @@ object PolyDefns extends Cases { object Compose { implicit def composeCase[C, F <: Poly, G <: Poly, T, U, V] - (implicit unpack: Unpack2[C, Compose, F, G], cG : Case1.Aux[G, T, U], cF : Case1.Aux[F, U, V]) = new Case[C, T :: HNil] { + (implicit unpack: Unpack2[C, Compose, F, G], cG : Case1.Aux[G, T, U], cF : Case1.Aux[F, U, V]): Case.Aux[C, T :: HNil, V] = new Case[C, T :: HNil] { type Result = V val value = (t : T :: HNil) => cF(cG.value(t)) } @@ -170,11 +170,11 @@ object PolyDefns extends Cases { * Base class for lifting a `Function1` to a `Poly1` */ class ->[T, R](f : T => R) extends Poly1 { - implicit def subT[U <: T] = at[U](f) + implicit def subT[U <: T]: Case.Aux[U, R] = at[U](f) } trait LowPriorityLiftFunction1 extends Poly1 { - implicit def default[T] = at[T](_ => HNil : HNil) + implicit def default[T]: Case.Aux[T, HNil] = at[T](_ => HNil : HNil) } /** @@ -182,11 +182,11 @@ object PolyDefns extends Cases { * its only element if the argument is in the original functions domain, `HNil` otherwise. */ class >->[T, R](f : T => R) extends LowPriorityLiftFunction1 { - implicit def subT[U <: T] = at[U](f(_) :: HNil) + implicit def subT[U <: T]: Case.Aux[U, R :: HNil] = at[U](f(_) :: HNil) } trait LowPriorityLiftU extends Poly { - implicit def default[L <: HList] = new ProductCase[L] { + implicit def default[L <: HList]: ProductCase.Aux[L, HNil] = new ProductCase[L] { type Result = HNil val value = (l : L) => HNil } @@ -197,7 +197,7 @@ object PolyDefns extends Cases { * only element if the argument is in the original functions domain, `HNil` otherwise. */ class LiftU[P <: Poly](p : P) extends LowPriorityLiftU { - implicit def defined[L <: HList](implicit caseT : Case[P, L]) = new ProductCase[L] { + implicit def defined[L <: HList](implicit caseT : Case[P, L]): ProductCase.Aux[L, caseT.Result :: HNil] = new ProductCase[L] { type Result = caseT.Result :: HNil val value = (l : L) => caseT(l) :: HNil } diff --git a/core/shared/src/main/scala/shapeless/syntax/sized.scala b/core/shared/src/main/scala/shapeless/syntax/sized.scala index a93a0a682..ab9333312 100644 --- a/core/shared/src/main/scala/shapeless/syntax/sized.scala +++ b/core/shared/src/main/scala/shapeless/syntax/sized.scala @@ -19,10 +19,10 @@ package syntax object sized { implicit def genTraversableSizedConv[Repr](cc : Repr) - (implicit iil: IsRegularIterable[Repr], ev : AdditiveCollection[Repr]) = + (implicit iil: IsRegularIterable[Repr], ev : AdditiveCollection[Repr]): SizedConv[Repr] = new SizedConv[Repr](cc) - implicit def stringSizedConv(s : String) = new SizedConv[String](s) + implicit def stringSizedConv(s : String): SizedConv[String] = new SizedConv[String](s) } final class SizedConv[Repr](r : Repr)(implicit iil: IsRegularIterable[Repr], ev2: AdditiveCollection[Repr]) { diff --git a/core/shared/src/main/scala/shapeless/syntax/std/functions.scala b/core/shared/src/main/scala/shapeless/syntax/std/functions.scala index 5aa6e1e39..0c1ae3189 100644 --- a/core/shared/src/main/scala/shapeless/syntax/std/functions.scala +++ b/core/shared/src/main/scala/shapeless/syntax/std/functions.scala @@ -29,12 +29,12 @@ package std object function { import ops.function._ - implicit def fnHListOps[F, T <: HList, R](t: F)(implicit fnHLister: FnToProduct.Aux[F, T => R]) = new FnHListOps[T => R] { + implicit def fnHListOps[F, T <: HList, R](t: F)(implicit fnHLister: FnToProduct.Aux[F, T => R]): FnHListOps[T => R] = new FnHListOps[T => R] { def toProduct = fnHLister(t) } - implicit def fnUnHListOps[F](t : F)(implicit fnUnHLister : FnFromProduct[F]) = new FnUnHListOps[fnUnHLister.Out] { + implicit def fnUnHListOps[F](t : F)(implicit fnUnHLister : FnFromProduct[F]): FnUnHListOps[fnUnHLister.Out] = new FnUnHListOps[fnUnHLister.Out] { def fromProduct = fnUnHLister(t) } } diff --git a/core/shared/src/main/scala/shapeless/syntax/std/maps.scala b/core/shared/src/main/scala/shapeless/syntax/std/maps.scala index 65cf90fd7..ba85c3b4e 100644 --- a/core/shared/src/main/scala/shapeless/syntax/std/maps.scala +++ b/core/shared/src/main/scala/shapeless/syntax/std/maps.scala @@ -23,7 +23,7 @@ import shapeless.ops.maps.FromMap * Conversions between `Map` and `Records`. */ object maps { - implicit def mapOps[K, V](m: Map[K, V]) = new MapOps[K, V](m) + implicit def mapOps[K, V](m: Map[K, V]): MapOps[K, V] = new MapOps[K, V](m) } final class MapOps[K, V](m: Map[K, V]) { diff --git a/core/shared/src/main/scala/shapeless/syntax/std/traversables.scala b/core/shared/src/main/scala/shapeless/syntax/std/traversables.scala index 1e1a6e720..3bbb719f7 100644 --- a/core/shared/src/main/scala/shapeless/syntax/std/traversables.scala +++ b/core/shared/src/main/scala/shapeless/syntax/std/traversables.scala @@ -28,8 +28,8 @@ package std * @author Rob Norris */ object traversable { - implicit def traversableOps[T](t : T)(implicit ev: T => Iterable[_]) = new TraversableOps(t) - implicit def traversableOps2[CC[T] <: Iterable[T], A](as: CC[A]) = new TraversableOps2(as) + implicit def traversableOps[T](t : T)(implicit ev: T => Iterable[_]): TraversableOps[T] = new TraversableOps(t) + implicit def traversableOps2[CC[T] <: Iterable[T], A](as: CC[A]): TraversableOps2[CC, A] = new TraversableOps2(as) } final class TraversableOps[T](t : T)(implicit ev: T => Iterable[_]) { diff --git a/core/shared/src/main/scala/shapeless/syntax/zipper.scala b/core/shared/src/main/scala/shapeless/syntax/zipper.scala index 1fb1eb5bf..1de1c3062 100644 --- a/core/shared/src/main/scala/shapeless/syntax/zipper.scala +++ b/core/shared/src/main/scala/shapeless/syntax/zipper.scala @@ -18,8 +18,8 @@ package shapeless package syntax object zipper { - implicit def toZipper[L <: HList](l: L) = new HListZipperOps(l) - implicit def toZipper[C, CL <: HList](c : C)(implicit gen : Generic.Aux[C, CL]) = new GenericZipperOps(c) + implicit def toZipper[L <: HList](l: L): HListZipperOps[L] = new HListZipperOps(l) + implicit def toZipper[C, CL <: HList](c : C)(implicit gen : Generic.Aux[C, CL]): GenericZipperOps[C, CL] = new GenericZipperOps(c) } /** Enhances values of any type with a representation via `Generic` with a method supporting conversion to a `Zipper`. */ diff --git a/core/shared/src/main/scala/shapeless/typeoperators.scala b/core/shared/src/main/scala/shapeless/typeoperators.scala index 98e731db4..1f26b83d4 100644 --- a/core/shared/src/main/scala/shapeless/typeoperators.scala +++ b/core/shared/src/main/scala/shapeless/typeoperators.scala @@ -195,7 +195,7 @@ trait Lub[-A, -B, Out] extends Serializable { } object Lub { - implicit def lub[T] = new Lub[T, T, T] { + implicit def lub[T]: Lub[T, T, T] = new Lub[T, T, T] { def left(a : T): T = a def right(b : T): T = b } diff --git a/core/shared/src/main/scala/shapeless/unwrapped.scala b/core/shared/src/main/scala/shapeless/unwrapped.scala index bedf51ada..ef8674d04 100644 --- a/core/shared/src/main/scala/shapeless/unwrapped.scala +++ b/core/shared/src/main/scala/shapeless/unwrapped.scala @@ -34,7 +34,7 @@ trait UnwrappedInstances extends LowPriorityUnwrappedInstances { gen: Generic.Aux[W, Repr], avh: AnyValHelper.Aux[Repr, UI], chain: Strict[Unwrapped.Aux[UI, UF]] - ) = new Unwrapped[W] { + ): Unwrapped.Aux[W, UF] = new Unwrapped[W] { type U = UF def unwrap(w: W): U = chain.value.unwrap(avh.unwrap(gen.to(w))) def wrap(u: U): W = gen.from(avh.wrap(chain.value.wrap(u))) @@ -47,7 +47,7 @@ trait UnwrappedInstances extends LowPriorityUnwrappedInstances { } object AnyValHelper { type Aux[Repr, U0] = AnyValHelper[Repr] { type U = U0 } - implicit def sizeOneHListHelper[T] = + implicit def sizeOneHListHelper[T]: Aux[T :: HNil, T] = SizeOneHListHelper.asInstanceOf[AnyValHelper.Aux[T :: HNil, T]] val SizeOneHListHelper = new AnyValHelper[Any :: HNil] { type U = Any @@ -58,11 +58,11 @@ trait UnwrappedInstances extends LowPriorityUnwrappedInstances { implicit def newtypeUnwrapped[UI, Ops, UF](implicit chain: Strict[Unwrapped.Aux[UI, UF]] - ) = chain.value.asInstanceOf[Unwrapped.Aux[Newtype[UI, Ops], UF]] + ): Unwrapped.Aux[Newtype[UI, Ops], UF] = chain.value.asInstanceOf[Unwrapped.Aux[Newtype[UI, Ops], UF]] implicit def tagUnwrapped[T[UI, TT] <: tag.@@[UI, TT], UI, TT, UF](implicit chain: Strict[Unwrapped.Aux[UI, UF]] - ) = chain.value.asInstanceOf[Unwrapped.Aux[T[UI, TT], UF]] + ): Unwrapped.Aux[T[UI, TT], UF] = chain.value.asInstanceOf[Unwrapped.Aux[T[UI, TT], UF]] } @@ -73,6 +73,6 @@ trait LowPriorityUnwrappedInstances { def unwrap(t: Any) = t def wrap(t: Any) = t } - implicit def selfUnwrapped[T] = + implicit def selfUnwrapped[T]: Unwrapped.Aux[T,T] = theSelfUnwrapped.asInstanceOf[Unwrapped.Aux[T, T]] } diff --git a/examples/src/main/scala/shapeless/examples/backtracking.scala b/examples/src/main/scala/shapeless/examples/backtracking.scala index 5dc7b9229..71571821b 100644 --- a/examples/src/main/scala/shapeless/examples/backtracking.scala +++ b/examples/src/main/scala/shapeless/examples/backtracking.scala @@ -26,10 +26,10 @@ object TypeLevelBacktrack extends App { // Given a genealogical tree, compute family relationship on the type level. // ------------------------------------------------------------------------- - /** [[Parent]] / [[Child]] relationship, father side. */ + /** `Parent` / `Child` relationship, father side. */ trait FatherOf[Parent, Child] - /** [[Parent]] / [[Child]] relationship, mother side. */ + /** `Parent` / `Child` relationship, mother side. */ trait MotherOf[Parent, Child] def fact[P, C](): FatherOf[P, C] = new FatherOf[P, C] {} @@ -56,7 +56,7 @@ object TypeLevelBacktrack extends App { // Translated to scala, it looks like the `IsAncestor` typeclass below. // ------------------------------------------------------------------------- - /** Typeclass witnessing that all [[Ancestor]] is an ancestor of [[Descendant]]. */ + /** Typeclass witnessing that all `Ancestor` is an ancestor of `Descendant`. */ trait IsAncestor[Ancestor, Descendant] object IsAncestor { @@ -100,7 +100,7 @@ object TypeLevelBacktrack extends App { // containment in in the list of all ancestors. // ------------------------------------------------------------------------- - /** Typeclass computing all the [[Ancestors]] of a [[Person]]. */ + /** Typeclass computing all the `Ancestors` of a `Person`. */ trait AllAncestors[Person, Ancestors <: HList] // This is used to lower the priority of the *base case*. @@ -125,7 +125,7 @@ object TypeLevelBacktrack extends App { ) = new AllAncestors[P, F :: M :: CA] {} } - /** Typeclass witnessing family relationship between [[P2]] and [[P1]]. */ + /** Typeclass witnessing family relationship between `P2` and `P1`. */ class Relationship[P1, P2] object Relationship { diff --git a/examples/src/main/scala/shapeless/examples/zipapply.scala b/examples/src/main/scala/shapeless/examples/zipapply.scala index 3031c8489..3017e8738 100644 --- a/examples/src/main/scala/shapeless/examples/zipapply.scala +++ b/examples/src/main/scala/shapeless/examples/zipapply.scala @@ -65,12 +65,13 @@ object ZipApplyExamples extends App { // A different type of HList of functions (it's specially planned - wait for the big twist!) val functions2 = (stringFunction _) :: (booleanFunction _) :: (intFunction _) :: (longFunction _) :: HNil + println(ZipApplyExample.inferenceResults) /** - * [[ZipApply]] allows application of an [[HList]] of functions to an [[HList]] of their corresponding arguments, - * resulting in an [[HList]] of the results of the applications. Here's an example. + * [[shapeless.ops.hlist.ZipApply]] allows application of an [[HList]] of functions to an [[HList]] of their + * corresponding arguments, resulting in an [[HList]] of the results of the applications. Here's an example. */ - def zipApplyExample() = { + object ZipApplyExample { // At a minimum, ZipApply requires the argument types to be known val zipApply = ZipApply[Functions, Args] @@ -96,13 +97,13 @@ object ZipApplyExamples extends App { * @param a An HList of arguments — each element must be of the input type of the corresponding function from f1 * * The implicits used: - * @param zip A [[Zip]] instance which allows us to zip f1 and f2, giving an HList with the corresponding - * elements from each f1 and f2 as a [[Tuple2]] - i.e. + * @param zip A [[shapeless.ops.hlist.Zip]] instance which allows us to zip f1 and f2, giving an HList with + * the corresponding elements from each f1 and f2 as a [[scala.Tuple2]] - i.e. * (f1.head, f2.head) :: (f1.drop(1).head, f2.drop(1).head) ... :: HNil - * @param mapCompose A [[Mapper]] instance which allows us to map the output of `zip` with the [[compose]] poly - * function (defined at the bottom of this file) - * @param zipApply A [[ZipApply]] instance which will perform the application of the composed functions. Note the - * use of `Aux` to infer the result type. + * @param mapCompose A [[shapeless.ops.hlist.Mapper]] instance which allows us to map the output of `zip` with the + * [[compose]] poly function (defined at the bottom of this file) + * @param zipApply A [[shapeless.ops.hlist.ZipApply]] instance which will perform the application of the composed + * functions. Note the use of `Aux` to infer the result type. * * And the type parameters: * @tparam Functions1 The type of the first [[HList]] of functions. This can be inferred because `inferenceExample` @@ -110,12 +111,12 @@ object ZipApplyExamples extends App { * @tparam Functions2 The type of the second [[HList]] of functions. This can be inferred for the same reason. * @tparam Arguments The type of the [[HList]] of arguments. Again, this can be inferred since it must be concrete * at the call site. - * @tparam FCombined The type of the [[HList]] of pairs zipped from [[Functions1]] and [[Functions2]]. This gets - * inferred thanks to the use of [[Zip.Aux]]. - * @tparam FComposed The type of the [[HList]] of composed functions from [[Functions1]] and [[Functions2]]. This - * gets inferred thanks to the use of [[Mapper.Aux]]. - * @tparam Output The type of the [[HList]] of results from applying [[FComposed]] to [[Arguments]]. This gets - * inferred thanks to the use of [[ZipApply.Aux]]. + * @tparam FCombined The type of the [[HList]] of pairs zipped from `Functions1` and `Functions2`. This gets + * inferred thanks to the use of [[shapeless.ops.hlist.Zip.Aux]]. + * @tparam FComposed The type of the [[HList]] of composed functions from `Functions1` and `Functions2`. This + * gets inferred thanks to the use of [[shapeless.ops.hlist.Mapper.Aux]]. + * @tparam Output The type of the [[HList]] of results from applying `FComposed` to `Arguments`. This gets + * inferred thanks to the use of [[shapeless.ops.hlist.ZipApply.Aux]]. * * @return The results of applying the composed functions to the corresponding arguments, as an HList. */ diff --git a/project/build.properties b/project/build.properties index 46e43a97e..04267b14a 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.8.2 +sbt.version=1.9.9 diff --git a/project/plugins.sbt b/project/plugins.sbt index cc44b4cb6..7e9c3e28c 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,13 +1,13 @@ scalacOptions += "-deprecation" -libraryDependencies += "org.slf4j" % "slf4j-nop" % "2.0.6" +libraryDependencies += "org.slf4j" % "slf4j-nop" % "2.0.13" -addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.1") -addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.6") -addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0") -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") +addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.3") +addSbtPlugin("com.github.sbt" % "sbt-osgi" % "0.10.0") +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.12.0") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12") addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.2") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.13.0") -addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.10") -addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0") -addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.17") +addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2") +addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.3.2") addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.13.0") diff --git a/scripts/try-shapeless.sh b/scripts/try-shapeless.sh index 28751918e..a2331a427 100755 --- a/scripts/try-shapeless.sh +++ b/scripts/try-shapeless.sh @@ -3,6 +3,6 @@ COURSIER_URL=https://get-coursier.io/coursier test -e ~/.coursier/coursier || \ (mkdir -p ~/.coursier && curl -L -s --output ~/.coursier/coursier $COURSIER_URL && chmod +x ~/.coursier/coursier) ~/.coursier/coursier launch -q -P -M ammonite.Main \ - com.lihaoyi:ammonite_2.13.0:1.6.8 \ - com.chuusai:shapeless_2.13:2.3.3 \ + com.lihaoyi:ammonite_2.13.10:2.5.8 \ + com.chuusai:shapeless_2.13:2.3.10 \ -- --predef-code 'import shapeless._' < /dev/tty