Skip to content

Commit

Permalink
Give some love to the project (#1175)
Browse files Browse the repository at this point in the history
* Give some love to the project

* Remove Scala 2.11 support

* scalafmt

* clean

* Remove weird warning

* Remove weird warning

* Remove weird warning

* scalafix

* Remove usages of deprecated methods

* Remove Silencer

* Remove Silencer

* clean
  • Loading branch information
guizmaii authored Aug 10, 2023
1 parent 5e62ee2 commit c0eb89f
Show file tree
Hide file tree
Showing 21 changed files with 73 additions and 148 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
strategy:
fail-fast: false
matrix:
scala: ['2.11.*', '2.12.*', '2.13.*', '3.*']
scala: ['2.12.*', '2.13.*', '3.*']
java: ['17']
platform: ['JVM']
steps:
Expand All @@ -118,9 +118,6 @@ jobs:
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 7
- name: tests 2.11
if: ${{ startsWith(matrix.scala, '2.11.') }}
run: free --si -tmws 10 & ./sbt ++${{ matrix.scala }} root211/test
- name: tests 2.12
if: ${{ startsWith(matrix.scala, '2.12.') }}
run: free --si -tmws 10 & ./sbt ++${{ matrix.scala }} root212/test
Expand Down
18 changes: 6 additions & 12 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import BuildHelper._

Global / onChangedBuildSource := ReloadOnSourceChanges

inThisBuild(
List(
organization := "dev.zio",
Expand Down Expand Up @@ -35,7 +37,7 @@ addCommandAlias(
";coreTestsNative/test;experimentalTestsNative/test" // `test` currently executes only compilation, see `nativeSettings` in `BuildHelper`
)

val zioVersion = "2.0.10"
val zioVersion = "2.0.15"

val projectsCommon = List(
core,
Expand Down Expand Up @@ -70,12 +72,6 @@ lazy val rootNative = project
.settings(publish / skip := true)
.aggregate(projectsCommon.map(_.native: ProjectReference): _*)

lazy val root211 = project
.in(file("target/root211"))
.settings(publish / skip := true)
.aggregate(projectsCommon.map(_.jvm: ProjectReference): _*)
.aggregate(scalaParallelCollections)

lazy val root212 = project
.in(file("target/root212"))
.settings(publish / skip := true)
Expand Down Expand Up @@ -217,10 +213,10 @@ lazy val scalaParallelCollections = project
.settings(
libraryDependencies ++= {
scalaVersion.value match {
// Only 2.11 and 2.12 standard library contains Parallel Scala collections
case BuildHelper.Scala211 | BuildHelper.Scala212 =>
// Only 2.12 standard library contains Parallel Scala collections
case BuildHelper.Scala212 =>
List()
case _ =>
case _ =>
List("org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.4")
}
}
Expand All @@ -233,7 +229,6 @@ lazy val benchmarks = project
.in(file("benchmarks"))
.settings(stdSettings("zio-prelude-benchmarks"))
.settings(
crossScalaVersions --= List(BuildHelper.Scala211),
publish / skip := true,
scalacOptions -= "-Yno-imports",
scalacOptions -= "-Xfatal-warnings",
Expand All @@ -252,7 +247,6 @@ lazy val docs = project
scalacOptions -= "-Yno-imports",
scalacOptions -= "-Xfatal-warnings",
scalaVersion := Scala213,
crossScalaVersions -= Scala211,
projectName := "ZIO Prelude",
mainModuleName := (core.jvm / moduleName).value,
projectStage := ProjectStage.ProductionReady,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import zio.prelude.NewtypeSpecTypes._
import zio.prelude.laws.{isFailureV, isSuccessV}
import zio.prelude.newtypes.{And, Or, Sum}
import zio.test.Assertion._
import zio.test.TestAspect._
import zio.test.{Assertion => TestAssertion, _}

import scala.reflect.ClassTag
Expand Down Expand Up @@ -68,7 +67,7 @@ object NewtypeSpec extends ZIOBaseSpec {
),
test("classtag reports same runtimeclass as underlying primitive") {
assert(implicitly[ClassTag[LuckyNumber]].runtimeClass eq implicitly[ClassTag[Double]].runtimeClass)(isTrue)
} @@ exceptScala211,
},
test("allows creating subtypes of newtypes") {
val compile = typeCheck {
"""import java.util.UUID
Expand All @@ -80,7 +79,7 @@ object NewtypeSpec extends ZIOBaseSpec {
"""
}
assertZIO(compile)(isRight)
} @@ TestAspect.exceptScala211,
},
test("allows creating arrays of newtypes") {
val data = Array.fill(2)(Natural(0))
data(1) = Natural(1)
Expand Down Expand Up @@ -109,7 +108,7 @@ object NewtypeSpec extends ZIOBaseSpec {
),
test("classtag reports same runtimeclass as underlying primitive") {
assert(implicitly[ClassTag[Natural]].runtimeClass eq implicitly[ClassTag[Int]].runtimeClass)(isTrue)
} @@ exceptScala211,
},
test("pattern matching") {
val number = Natural(2)
assertTrue(
Expand Down

This file was deleted.

21 changes: 0 additions & 21 deletions core/shared/src/main/scala-2.11/zio/prelude/Subtype.scala

This file was deleted.

12 changes: 6 additions & 6 deletions core/shared/src/main/scala-3/zio/prelude/Liftables.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ trait Liftables {
case '{ Assertion.Regex.digit } => Some(Assertion.Regex.digit)
case '{ Assertion.Regex.nonDigit } => Some(Assertion.Regex.nonDigit)
case '{ Assertion.Regex.literal(${Expr(str)}) } => Some(Assertion.Regex.literal(str))
case '{ Assertion.Regex.anyCharOf(${Expr(first)}, ${Expr(second)}, ${Varargs(rest)}: _*) } => Some(Assertion.Regex.anyCharOf(first, second, Varargs(rest).valueOrError*))
case '{ Assertion.Regex.anyRegexOf(${Expr(first)}, ${Expr(second)}, ${Varargs(rest)}: _*) } => Some(Assertion.Regex.anyRegexOf(first, second, Varargs(rest).valueOrError*))
case '{ Assertion.Regex.notAnyCharOf(${Expr(first)}, ${Expr(second)}, ${Varargs(rest)}: _*) } => Some(Assertion.Regex.notAnyCharOf(first, second, Varargs(rest).valueOrError*))
case '{ Assertion.Regex.notAnyRegexOf(${Expr(first)}, ${Expr(second)}, ${Varargs(rest)}: _*) } => Some(Assertion.Regex.notAnyRegexOf(first, second, Varargs(rest).valueOrError*))
case '{ Assertion.Regex.anyCharOf(${Expr(first)}, ${Expr(second)}, ${Varargs(rest)}: _*) } => Some(Assertion.Regex.anyCharOf(first, second, Varargs(rest).valueOrAbort*))
case '{ Assertion.Regex.anyRegexOf(${Expr(first)}, ${Expr(second)}, ${Varargs(rest)}: _*) } => Some(Assertion.Regex.anyRegexOf(first, second, Varargs(rest).valueOrAbort*))
case '{ Assertion.Regex.notAnyCharOf(${Expr(first)}, ${Expr(second)}, ${Varargs(rest)}: _*) } => Some(Assertion.Regex.notAnyCharOf(first, second, Varargs(rest).valueOrAbort*))
case '{ Assertion.Regex.notAnyRegexOf(${Expr(first)}, ${Expr(second)}, ${Varargs(rest)}: _*) } => Some(Assertion.Regex.notAnyRegexOf(first, second, Varargs(rest).valueOrAbort*))
case '{ Assertion.Regex.inRange(${Expr(start)}, ${Expr(end)}) } => Some(Assertion.Regex.inRange(start, end))
case '{ Assertion.Regex.notInRange(${Expr(start)}, ${Expr(end)}) } => Some(Assertion.Regex.notInRange(start, end))
case '{ Assertion.Regex.start } => Some(Assertion.Regex.start)
Expand Down Expand Up @@ -130,7 +130,7 @@ trait Liftables {
case _: Short => summon[Numeric[Short]].asInstanceOf[Numeric[Any]]
case _: Byte => summon[Numeric[Byte]].asInstanceOf[Numeric[Any]]
case _: Char => summon[Numeric[Char]].asInstanceOf[Numeric[Any]]
case other => report.throwError(s"NO NUMERIC FOR $other")
case other => report.errorAndAbort(s"NO NUMERIC FOR $other")
}
}

Expand All @@ -146,7 +146,7 @@ trait Liftables {
case _: Short => SOrdering.Short.asInstanceOf[SOrdering[Any]]
case _: Byte => SOrdering.Byte.asInstanceOf[SOrdering[Any]]
case _: Char => SOrdering.Char.asInstanceOf[SOrdering[Any]]
case other => report.throwError(s"NO ORDERING FOR $other")
case other => report.errorAndAbort(s"NO ORDERING FOR $other")
}
}
}
3 changes: 2 additions & 1 deletion core/shared/src/main/scala/zio/prelude/Equal.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import zio.Exit.{Failure, Success}
import zio.prelude.coherent.{HashOrd, HashPartialOrd}
import zio.{Cause, Chunk, Duration => ZIODuration, Exit, FiberId, NonEmptyChunk, StackTrace}

import scala.annotation.implicitNotFound
import scala.annotation.{implicitNotFound, nowarn}
import scala.concurrent.duration.{Duration => ScalaDuration}
import scala.util.Try
import scala.{math => sm}
Expand Down Expand Up @@ -862,6 +862,7 @@ object Equal extends EqualVersionSpecific {
* `Hash` and `Ord` (and thus also `Equal`) instance for `Unit` values.
* Since there is only one `Unit` value all equality comparisons will always be true.
*/
@nowarn("msg=dubious usage of method hashCode with unit value")
implicit val UnitHashOrd: Hash[Unit] with Ord[Unit] =
HashOrd.make(_.hashCode, (_, _) => Ordering.Equals, (_, _) => true)

Expand Down
6 changes: 2 additions & 4 deletions core/shared/src/main/scala/zio/prelude/IdentityBoth.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

package zio.prelude

import com.github.ghik.silencer.silent

import scala.annotation.implicitNotFound
import scala.annotation.{implicitNotFound, nowarn}

/**
* A binary operator that combines two values of types `F[A]` and `F[B]` to
Expand All @@ -34,7 +32,7 @@ trait IdentityBoth[F[_]] extends AssociativeBoth[F] {
def any: F[Any]
}

@silent("Unused import")
@nowarn("msg=Unused import")
object IdentityBoth {
import zio._ // for zio.EitherCompat

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package zio.prelude

import com.github.ghik.silencer.silent
import scala.annotation.nowarn

@silent("Unused import")
@nowarn("msg=Unused import")
trait PartialEquivalence[A, B, +E1, +E2] { self =>
import PartialEquivalence._
import zio._ // for zio.EitherCompat
Expand Down
5 changes: 2 additions & 3 deletions core/shared/src/main/scala/zio/prelude/fx/ZPure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@

package zio.prelude.fx

import com.github.ghik.silencer.silent
import zio.internal.Stack
import zio.prelude._
import zio.prelude.coherent.CovariantIdentityBoth
import zio.{Cause => _, _}

import scala.annotation.switch
import scala.annotation.{nowarn, switch}
import scala.reflect.ClassTag
import scala.util.Try

Expand Down Expand Up @@ -1292,7 +1291,7 @@ object ZPure {
self.refineOrDie { case e: E1 => e }
}

@silent("never used")
@nowarn("msg=never used")
private object Tags {
final val FlatMap = 0
final val Succeed = 1
Expand Down
10 changes: 5 additions & 5 deletions macros/shared/src/main/scala-2/zio/prelude/Liftables.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package zio.prelude

import com.github.ghik.silencer.silent
import zio.prelude.Assertion.Regex

import scala.annotation.nowarn
import scala.reflect.macros.whitebox

// Wrongly emits warnings on Scala 2.12.x https://github.com/scala/bug/issues/11918
@silent("pattern var .* in method unapply is never used: use a wildcard `_` or suppress this warning with .*")
@nowarn("msg=pattern var .* in method unapply is never used: use a wildcard `_` or suppress this warning with .*")
trait Liftables {
val c: whitebox.Context

Expand Down Expand Up @@ -138,7 +138,7 @@ trait Liftables {
case q"scala.this.Predef.augmentString(${string: String}).r" => string.r
}

@silent("Implicit resolves to enclosing method")
@nowarn("msg=Implicit resolves to enclosing method")
implicit def assertionUnliftable[A]: Unliftable[Assertion[A]] =
Unliftable[Assertion[A]] {

Expand Down Expand Up @@ -265,14 +265,14 @@ trait Liftables {
}

/**
* This Ordering instance exists for compatibility between 2.11, 2.12 and 2.13.
* This Ordering instance exists for compatibility between 2.12 and 2.13.
*/
object DoubleOrdering extends Ordering[Double] {
def compare(x: Double, y: Double): Int = java.lang.Double.compare(x, y)
}

/**
* This Ordering instance exists for compatibility between 2.11, 2.12 and 2.13.
* This Ordering instance exists for compatibility between 2.12 and 2.13.
*/
object FloatOrdering extends Ordering[Float] {
def compare(x: Float, y: Float): Int = java.lang.Float.compare(x, y)
Expand Down
5 changes: 2 additions & 3 deletions macros/shared/src/main/scala-2/zio/prelude/Macros.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package zio.prelude

import com.github.ghik.silencer.silent
import zio.prelude.ConsoleUtils._

import scala.annotation.StaticAnnotation
import scala.annotation.{StaticAnnotation, nowarn}
import scala.reflect.macros.whitebox

final case class assertionQuote[A](assertion: Assertion[A]) extends StaticAnnotation
Expand All @@ -15,7 +14,7 @@ trait QuotedAssertion[A] {
}

// Wrongly emits warnings on Scala 2.12.x https://github.com/scala/bug/issues/11918
@silent("pattern var .* in method unapply is never used: use a wildcard `_` or suppress this warning with .*")
@nowarn("msg=pattern var .* in method unapply is never used: use a wildcard `_` or suppress this warning with .*")
private[prelude] class Macros(val c: whitebox.Context) extends Liftables {
import c.universe._

Expand Down
Loading

0 comments on commit c0eb89f

Please sign in to comment.