Skip to content

Commit

Permalink
Update Dependencies (zio#8436)
Browse files Browse the repository at this point in the history
* update dependencies

* format

* fix version specific issue

* fix test

* fix scalafix

* fix conflict

* remove silencer

* cleanup

* fix test

* fix warnings

* fix warnings
  • Loading branch information
adamgfraser authored Sep 20, 2023
1 parent 49ea59a commit 65f0a08
Show file tree
Hide file tree
Showing 31 changed files with 183 additions and 227 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ jobs:
strategy:
fail-fast: false
matrix:
scala: ['2.12.17', '2.13.10', '3.3.0']
scala: ['2.12.18', '2.13.12', '3.3.1']
java: ['17']
platform: ['JVM']
steps:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package zio.internal

import com.github.ghik.silencer.silent
import org.openjdk.jmh.annotations._
import org.openjdk.jmh.infra.Blackhole
import org.springframework.util.{ConcurrentReferenceHashMap => SpringConcurrentReferenceHashMap}
Expand All @@ -9,6 +8,7 @@ import java.util
import java.util.Collections
import java.util.concurrent.{ConcurrentLinkedQueue, TimeUnit}
import java.util.concurrent.atomic.AtomicInteger
import scala.annotation.nowarn

@State(Scope.Benchmark)
private[this] class AddContext extends BaseContext {
Expand Down Expand Up @@ -255,7 +255,7 @@ private[this] class BaseContext {
protected def createJavaSet(values: Array[TestKey] = new Array[TestKey](0)): util.Set[TestKey] = {
import scala.jdk.CollectionConverters._
val set = Collections.synchronizedSet(Collections.newSetFromMap(new util.WeakHashMap[TestKey, java.lang.Boolean]()))
set.addAll(values.toSet.asJava): @silent("JavaConverters")
set.addAll(values.toSet.asJava): @nowarn("msg=JavaConverters")
set
}

Expand All @@ -265,7 +265,7 @@ private[this] class BaseContext {
import scala.jdk.CollectionConverters._
val map =
new SpringConcurrentReferenceHashMap[TestKey, Boolean](16, SpringConcurrentReferenceHashMap.ReferenceType.WEAK)
map.putAll(values.map((_, true)).toMap.asJava): @silent("JavaConverters")
map.putAll(values.map((_, true)).toMap.asJava): @nowarn("msg=JavaConverters")
map
}

Expand Down
218 changes: 95 additions & 123 deletions build.sbt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package zio.concurrent
import zio.{Chunk, ChunkBuilder, UIO, ZIO}

import java.util.concurrent.ConcurrentHashMap
import com.github.ghik.silencer.silent

import java.util.function.BiConsumer
import scala.annotation.nowarn
import scala.collection.JavaConverters._

/**
Expand Down Expand Up @@ -111,7 +111,7 @@ final class ConcurrentMap[K, V] private (private val underlying: ConcurrentHashM
* Adds all new key-value pairs
*/
def putAll(keyValues: (K, V)*): UIO[Unit] =
ZIO.succeed(underlying.putAll(keyValues.toMap.asJava): @silent("JavaConverters"))
ZIO.succeed(underlying.putAll(keyValues.toMap.asJava): @nowarn("msg=JavaConverters"))

/**
* Adds a new key-value pair, unless the key is already bound to some other
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package zio.concurrent

import com.github.ghik.silencer.silent
import zio.{UIO, ZIO}

import java.util.concurrent.ConcurrentHashMap
import java.util.function.{Consumer, Predicate}
import scala.annotation.nowarn
import scala.collection.JavaConverters._

/**
Expand All @@ -24,7 +24,7 @@ final class ConcurrentSet[A] private (private val underlying: ConcurrentHashMap.
* Adds all new values.
*/
def addAll(xs: Iterable[A]): UIO[Boolean] =
ZIO.succeed(underlying.addAll(xs.asJavaCollection): @silent("JavaConverters"))
ZIO.succeed(underlying.addAll(xs.asJavaCollection): @nowarn("msg=JavaConverters"))

/**
* Removes all elements.
Expand Down Expand Up @@ -139,7 +139,7 @@ final class ConcurrentSet[A] private (private val underlying: ConcurrentHashMap.
* existing element.
*/
def removeAll(xs: Iterable[A]): UIO[Boolean] =
ZIO.succeed(underlying.removeAll(xs.asJavaCollection): @silent("JavaConverters"))
ZIO.succeed(underlying.removeAll(xs.asJavaCollection): @nowarn("msg=JavaConverters"))

/**
* Removes all elements which satisfy the given predicate.
Expand All @@ -152,7 +152,7 @@ final class ConcurrentSet[A] private (private val underlying: ConcurrentHashMap.
* existing element.
*/
def retainAll(xs: Iterable[A]): UIO[Boolean] =
ZIO.succeed(underlying.retainAll(xs.asJavaCollection): @silent("JavaConverters"))
ZIO.succeed(underlying.retainAll(xs.asJavaCollection): @nowarn("msg=JavaConverters"))

/**
* Removes all elements which do not satisfy the given predicate.
Expand All @@ -170,12 +170,12 @@ final class ConcurrentSet[A] private (private val underlying: ConcurrentHashMap.
* Convert the ConcurrentSet to Set.
*/
def toSet: UIO[Set[A]] =
ZIO.succeed(underlying.asScala.toSet: @silent("JavaConverters"))
ZIO.succeed(underlying.asScala.toSet: @nowarn("msg=JavaConverters"))

/**
* Transform all elements of the ConcurrentSet using the given function.
*/
@silent("JavaConverters")
@nowarn("msg=JavaConverters")
def transform(f: A => A): UIO[Unit] =
ZIO.succeed {
val set = underlying.asScala.toSet
Expand Down
5 changes: 3 additions & 2 deletions core-tests/shared/src/test/scala/REPLSpec.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import com.github.ghik.silencer.silent
import zio.test._

import scala.annotation.nowarn

object REPLSpec extends ZIOSpecDefault {

def spec = suite("REPLSpec")(
test("settings compile") {
import zio._
@silent("never used")
@nowarn("msg=never used")
implicit class RunSyntax[A](io: ZIO[Any, Any, A]) {
def unsafeRun: A =
Unsafe.unsafe { implicit unsafe =>
Expand Down
8 changes: 4 additions & 4 deletions core-tests/shared/src/test/scala/zio/CanFailSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ object CanFailSpec extends ZIOBaseSpec {
val result = typeCheck {
"""
import zio._
val io = ZIO.attempt(1 / 0)
val uio = ZIO.succeed(0)
val io = ZIO.attempt("io")
val uio = ZIO.succeed("uio")
io.orElse(uio)
"""
}
Expand All @@ -21,8 +21,8 @@ object CanFailSpec extends ZIOBaseSpec {
val result = typeCheck {
"""
import zio._
val io = ZIO.attempt(1 / 0)
val uio = ZIO.succeed(0)
val io = ZIO.attempt("io")
val uio = ZIO.succeed("uio")
uio.orElse(io)
"""
}
Expand Down
4 changes: 2 additions & 2 deletions core-tests/shared/src/test/scala/zio/ZIOSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4268,11 +4268,11 @@ object ZIOSpec extends ZIOBaseSpec {
}
},
test("promise ugly path test") {
val func: String => String = s => s.toUpperCase
val func: String => String = _ => throw new Exception("side-effect")
for {
promise <- ZIO.succeed(scala.concurrent.Promise[String]())
_ <- ZIO.attempt {
Try(func(null)) match {
Try(func("hello world from future")) match {
case Success(value) => promise.success(value)
case Failure(exception) => promise.failure(exception)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package zio

import com.github.ghik.silencer.silent
import zio.test.Assertion._
import zio.test._

@silent("never used")
import scala.annotation.nowarn

@nowarn("msg=never used")
object ZLayerDerivationSpec extends ZIOBaseSpec {

override def spec = suite("ZLayer.derive[A]")(
Expand Down
6 changes: 2 additions & 4 deletions core/jvm/src/main/scala/zio/metrics/jvm/BufferPools.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package zio.metrics.jvm

import com.github.ghik.silencer.silent

import zio._
import zio.metrics._

import java.lang.management.{BufferPoolMXBean, ManagementFactory}

import scala.annotation.nowarn
import scala.collection.JavaConverters._

final case class BufferPools(
Expand All @@ -16,7 +14,7 @@ final case class BufferPools(
)

object BufferPools {
@silent("JavaConverters")
@nowarn("msg=JavaConverters")
val live: ZLayer[JvmMetricsSchedule, Throwable, Reloadable[BufferPools]] =
ZLayer.scoped {
for {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package zio.metrics.jvm

import com.github.ghik.silencer.silent
import zio._
import zio.metrics._

import java.lang.management.ManagementFactory
import scala.annotation.nowarn
import scala.collection.JavaConverters._

final case class GarbageCollector(
Expand All @@ -13,7 +13,7 @@ final case class GarbageCollector(
)

object GarbageCollector {
@silent("JavaConverters")
@nowarn("msg=JavaConverters")
val live: ZLayer[JvmMetricsSchedule, Throwable, GarbageCollector] =
ZLayer.scoped {
for {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package zio.metrics.jvm

import com.github.ghik.silencer.silent
import com.sun.management.GarbageCollectionNotificationInfo
import zio._
import zio.metrics.Metric.Counter
Expand All @@ -9,6 +8,7 @@ import zio.metrics._
import java.lang.management.{GarbageCollectorMXBean, ManagementFactory}
import javax.management.openmbean.CompositeData
import javax.management.{Notification, NotificationEmitter, NotificationListener}
import scala.annotation.nowarn
import scala.collection.JavaConverters._
import scala.collection.mutable

Expand All @@ -26,7 +26,7 @@ object MemoryAllocation {
private class Listener(runtime: Runtime[Any]) extends NotificationListener {
private val lastMemoryUsage: mutable.Map[String, Long] = mutable.HashMap.empty

@silent("JavaConverters")
@nowarn("msg=JavaConverters")
override def handleNotification(notification: Notification, handback: Any): Unit = {
val info =
GarbageCollectionNotificationInfo.from(notification.getUserData.asInstanceOf[CompositeData])
Expand Down Expand Up @@ -72,7 +72,7 @@ object MemoryAllocation {
}
}

@silent("JavaConverters")
@nowarn("msg=JavaConverters")
val live: ZLayer[Any, Throwable, MemoryAllocation] =
ZLayer.scoped {
ZIO
Expand Down
4 changes: 2 additions & 2 deletions core/jvm/src/main/scala/zio/metrics/jvm/MemoryPools.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package zio.metrics.jvm

import com.github.ghik.silencer.silent
import zio._
import zio.metrics.MetricKeyType.Gauge
import zio.metrics._

import java.lang.management.{ManagementFactory, MemoryPoolMXBean, MemoryUsage}
import scala.annotation.nowarn
import scala.collection.JavaConverters._

final case class MemoryPools(
Expand Down Expand Up @@ -81,7 +81,7 @@ object MemoryPools {
)
)

@silent("JavaConverters")
@nowarn("msg=JavaConverters")
val live: ZLayer[JvmMetricsSchedule, Throwable, MemoryPools] =
ZLayer.scoped {
for {
Expand Down
7 changes: 3 additions & 4 deletions core/shared/src/main/scala/zio/System.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ package zio
import zio.internal.stacktracer.Tracer
import zio.stacktracer.TracingImplicits.disableAutoTrace

import com.github.ghik.silencer.silent

import java.lang.{System => JSystem}
import scala.annotation.nowarn
import scala.collection.JavaConverters._

trait System extends Serializable { self =>
Expand Down Expand Up @@ -149,14 +148,14 @@ object System extends Serializable {
override def envOrOption(variable: String, alt: => Option[String])(implicit unsafe: Unsafe): Option[String] =
envOrOptionWith(variable, alt)(env)

@silent("JavaConverters")
@nowarn("msg=JavaConverters")
override def envs()(implicit unsafe: Unsafe): Map[String, String] =
JSystem.getenv.asScala.toMap

override def lineSeparator()(implicit unsafe: Unsafe): String =
JSystem.lineSeparator

@silent("JavaConverters")
@nowarn("msg=JavaConverters")
override def properties()(implicit unsafe: Unsafe): Map[String, String] =
JSystem.getProperties.asScala.toMap

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

package zio.internal

import com.github.ghik.silencer.silent
import zio.Chunk
import zio.stacktracer.TracingImplicits.disableAutoTrace

import java.util.concurrent.ConcurrentLinkedQueue
import java.util.concurrent.atomic.AtomicLong
import scala.annotation.nowarn

private[zio] final class LinkedQueue[A] extends MutableConcurrentQueue[A] with Serializable {
override final val capacity = Int.MaxValue
Expand Down Expand Up @@ -50,7 +50,7 @@ private[zio] final class LinkedQueue[A] extends MutableConcurrentQueue[A] with S

override def offerAll[A1 <: A](as: Iterable[A1]): Chunk[A1] = {
import collection.JavaConverters._
jucConcurrentQueue.addAll(as.asJavaCollection): @silent("JavaConverters")
jucConcurrentQueue.addAll(as.asJavaCollection): @nowarn("msg=JavaConverters")
enqueuedCounter.addAndGet(as.size.toLong)
Chunk.empty
}
Expand Down
5 changes: 2 additions & 3 deletions core/shared/src/main/scala/zio/stm/ZSTM.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@

package zio.stm

import com.github.ghik.silencer.silent
import zio._
import zio.internal.{Stack, Sync}
import zio.stacktracer.TracingImplicits.disableAutoTrace

import java.util.concurrent.atomic.{AtomicLong, AtomicReference}
import java.util.{HashMap => MutableMap}
import scala.annotation.tailrec
import scala.annotation.{nowarn, tailrec}
import scala.collection.mutable.Builder
import scala.util.{Failure, Success, Try}

Expand Down Expand Up @@ -1712,7 +1711,7 @@ object ZSTM {

loop = !todo.compareAndSet(oldTodo, emptyTodo)

if (!loop) allTodos.putAll(oldTodo.asJava): @silent("JavaConverters")
if (!loop) allTodos.putAll(oldTodo.asJava): @nowarn("msg=JavaConverters")
}
}

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

package zio.macros

import com.github.ghik.silencer.silent

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

private[macros] abstract class AccessibleMMacroBase(override val c: whitebox.Context) extends AccessibleMacroBase(c) {
Expand All @@ -28,7 +27,7 @@ private[macros] abstract class AccessibleMMacroBase(override val c: whitebox.Con

protected def aliases: Seq[Tree]

@silent("pattern var [^\\s]+ in method unapply is never used")
@nowarn("msg=pattern var [^\\s]+ in method unapply is never used")
protected val tp: Tree = c.prefix.tree match {
case q"new ${macroNm: Ident}[$typeParam]" if macroNm.name == TypeName(macroName) =>
typeParam
Expand All @@ -47,7 +46,7 @@ private[macros] abstract class AccessibleMMacroBase(override val c: whitebox.Con
private lazy val types: Map[Type, Tree] =
aliases.map(a => c.typecheck(tq"$a", c.TYPEmode).tpe -> a).toMap

@silent("pattern var [^\\s]+ in method unapply is never used")
@nowarn("msg=pattern var [^\\s]+ in method unapply is never used")
protected def macroApply(annottees: Seq[c.Tree]): MacroApply = new MacroApply(annottees) {

private val typeParamToInject = {
Expand Down
Loading

0 comments on commit 65f0a08

Please sign in to comment.