Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Switch to new new wildcard [?]. #971

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 12 additions & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version = 3.7.14
runner.dialect = scala213
runner.dialect = scala213source3
project.git = true
style = defaultWithAlign
docstrings.style = Asterisk
Expand Down Expand Up @@ -75,3 +75,14 @@ project.excludeFilters = [
"scripts/authors.scala"
]
project.layout = StandardConvention

# Have to turn if off for now, scala-cli fmt not working for rewrite.
# The rewriting works when do rewriting with `sbt scalafmtAll`.
//rewrite.scala3.convertToNewSyntax = true
//runner {
// dialectOverride {
// allowAsForImportRename = false
// allowStarWildcardImport = false
// allowPostfixStarVarargSplices = false
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ object Effect {
with Serializable {

override def equals(other: Any) = other match {
case o: Spawned[_] =>
case o: Spawned[?] =>
this.behavior == o.behavior &&
this.childName == o.childName &&
this.props == o.props
Expand All @@ -58,7 +58,7 @@ object Effect {
override def _1: Behavior[T] = behavior
override def _2: String = childName
override def _3: Props = props
override def canEqual(o: Any) = o.isInstanceOf[Spawned[_]]
override def canEqual(o: Any) = o.isInstanceOf[Spawned[?]]
}

object Spawned {
Expand All @@ -76,7 +76,7 @@ object Effect {
with Serializable {

override def equals(other: Any) = other match {
case o: SpawnedAnonymous[_] => this.behavior == o.behavior && this.props == o.props
case o: SpawnedAnonymous[?] => this.behavior == o.behavior && this.props == o.props
case _ => false
}
override def hashCode: Int = behavior.## * 31 + props.##
Expand All @@ -85,7 +85,7 @@ object Effect {
override def productPrefix = "SpawnedAnonymous"
override def _1: Behavior[T] = behavior
override def _2: Props = props
override def canEqual(o: Any) = o.isInstanceOf[SpawnedAnonymous[_]]
override def canEqual(o: Any) = o.isInstanceOf[SpawnedAnonymous[?]]
}

object SpawnedAnonymous {
Expand All @@ -105,15 +105,15 @@ object Effect {
with Serializable {

override def equals(other: Any) = other match {
case o: SpawnedAdapter[_] => this.name == o.name
case o: SpawnedAdapter[?] => this.name == o.name
case _ => false
}
override def hashCode: Int = name.##
override def toString: String = s"SpawnedAdapter($name)"

override def productPrefix = "SpawnedAdapter"
override def _1: String = name
override def canEqual(o: Any) = o.isInstanceOf[SpawnedAdapter[_]]
override def canEqual(o: Any) = o.isInstanceOf[SpawnedAdapter[?]]
}

/**
Expand All @@ -137,17 +137,17 @@ object Effect {
with Serializable {

override def equals(other: Any): Boolean = other match {
case _: SpawnedAnonymousAdapter[_] => true
case _: SpawnedAnonymousAdapter[?] => true
case _ => false
}
override def hashCode: Int = Nil.##
override def toString: String = "SpawnedAnonymousAdapter"

override def productPrefix: String = "SpawnedAnonymousAdapter"
override def productIterator: Iterator[_] = Iterator.empty
override def productIterator: Iterator[?] = Iterator.empty
override def productArity: Int = 0
override def productElement(n: Int) = throw new NoSuchElementException
override def canEqual(o: Any): Boolean = o.isInstanceOf[SpawnedAnonymousAdapter[_]]
override def canEqual(o: Any): Boolean = o.isInstanceOf[SpawnedAnonymousAdapter[?]]
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ object TestKitSettings {
/**
* Reads configuration settings from `pekko.actor.testkit.typed` section.
*/
def apply(system: ActorSystem[_]): TestKitSettings =
def apply(system: ActorSystem[?]): TestKitSettings =
Ext(system).settings

/**
Expand All @@ -42,7 +42,7 @@ object TestKitSettings {
/**
* Java API: Reads configuration settings from `pekko.actor.testkit.typed` section.
*/
def create(system: ActorSystem[_]): TestKitSettings =
def create(system: ActorSystem[?]): TestKitSettings =
apply(system)

/**
Expand All @@ -53,11 +53,11 @@ object TestKitSettings {
new TestKitSettings(config)

private object Ext extends ExtensionId[Ext] {
override def createExtension(system: ActorSystem[_]): Ext = new Ext(system)
def get(system: ActorSystem[_]): Ext = Ext.apply(system)
override def createExtension(system: ActorSystem[?]): Ext = new Ext(system)
def get(system: ActorSystem[?]): Ext = Ext.apply(system)
}

private class Ext(system: ActorSystem[_]) extends Extension {
private class Ext(system: ActorSystem[?]) extends Extension {
val settings: TestKitSettings = TestKitSettings(system.settings.config.getConfig("pekko.actor.testkit.typed"))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ import pekko.util.FutureConverters._
override def extension[T <: Extension](ext: ExtensionId[T]): T =
throw new UnsupportedOperationException("ActorSystemStub cannot register extensions")

override def hasExtension(ext: ExtensionId[_ <: Extension]): Boolean =
override def hasExtension(ext: ExtensionId[? <: Extension]): Boolean =
throw new UnsupportedOperationException("ActorSystemStub cannot register extensions")

override def log: Logger = LoggerFactory.getLogger(getClass)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import pekko.testkit.TestKit
source: Option[String],
messageContains: Option[String],
messageRegex: Option[Regex],
cause: Option[Class[_ <: Throwable]],
cause: Option[Class[? <: Throwable]],
mdc: Map[String, String],
checkExcess: Boolean,
custom: Option[Function[LoggingEvent, Boolean]])
Expand Down Expand Up @@ -95,7 +95,7 @@ import pekko.testkit.TestKit
todo > 0
}

override def expect[T](code: => T)(implicit system: ActorSystem[_]): T = {
override def expect[T](code: => T)(implicit system: ActorSystem[?]): T = {
val effectiveLoggerName = loggerName.getOrElse("")
checkLogback(system)
TestAppender.setupTestAppender(effectiveLoggerName)
Expand All @@ -120,14 +120,14 @@ import pekko.testkit.TestKit
}
}

override def expect[T](system: ActorSystem[_], code: Supplier[T]): T =
override def expect[T](system: ActorSystem[?], code: Supplier[T]): T =
expect(code.get())(system)

// deprecated (renamed to expect)
override def intercept[T](code: => T)(implicit system: ActorSystem[_]): T =
override def intercept[T](code: => T)(implicit system: ActorSystem[?]): T =
expect(code)(system)

private def checkLogback(system: ActorSystem[_]): Unit = {
private def checkLogback(system: ActorSystem[?]): Unit = {
if (!system.dynamicAccess.classIsOnClasspath("ch.qos.logback.classic.spi.ILoggingEvent")) {
throw new IllegalStateException("LoggingEventFilter requires logback-classic dependency in classpath.")
}
Expand Down Expand Up @@ -170,7 +170,7 @@ import pekko.testkit.TestKit
override def withCustom(newCustom: Function[LoggingEvent, Boolean]): LoggingTestKitImpl =
copy(custom = Option(newCustom))

override def withCause(newCause: Class[_ <: Throwable]): javadsl.LoggingTestKit =
override def withCause(newCause: Class[? <: Throwable]): javadsl.LoggingTestKit =
copy(cause = Option(newCause))

}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private[pekko] final class FunctionRef[-T](override val path: ActorPath, send: (
@InternalApi private[pekko] val selfInbox = new TestInboxImpl[T](path)

override val self = selfInbox.ref
private var _children = TreeMap.empty[String, BehaviorTestKitImpl[_]]
private var _children = TreeMap.empty[String, BehaviorTestKitImpl[?]]
private val childName = Iterator.from(0).map(Helpers.base64(_))
private val substituteLoggerFactory = new SubstituteLoggerFactory
private val logger: Logger = substituteLoggerFactory.getLogger("StubbedLogger")
Expand Down Expand Up @@ -228,7 +228,7 @@ private[pekko] final class FunctionRef[-T](override val path: ActorPath, send: (
checkCurrentActorThread()
}

override def setLoggerName(clazz: Class[_]): Unit = {
override def setLoggerName(clazz: Class[?]): Unit = {
// nop as we don't track logger
checkCurrentActorThread()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private[pekko] object TestKitUtils {
// common internal utility impls for Java and Scala
private val TestKitRegex = """org\.apache\.pekko\.testkit\.typed\.(?:javadsl|scaladsl)\.ActorTestKit(?:\$.*)?""".r

def testNameFromCallStack(classToStartFrom: Class[_]): String =
def testNameFromCallStack(classToStartFrom: Class[?]): String =
pekko.testkit.TestKitUtils.testNameFromCallStack(classToStartFrom, TestKitRegex)

/**
Expand All @@ -90,7 +90,7 @@ private[pekko] object TestKitUtils {
def scrubActorSystemName(name: String): String =
pekko.testkit.TestKitUtils.scrubActorSystemName(name)

def shutdown(system: ActorSystem[_], timeout: Duration, throwIfShutdownTimesOut: Boolean): Unit = {
def shutdown(system: ActorSystem[?], timeout: Duration, throwIfShutdownTimesOut: Boolean): Unit = {
system.terminate()
try Await.ready(system.whenTerminated, timeout)
catch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private[pekko] object TestProbeImpl {
}

@InternalApi
private[pekko] final class TestProbeImpl[M](name: String, system: ActorSystem[_])
private[pekko] final class TestProbeImpl[M](name: String, system: ActorSystem[?])
extends JavaTestProbe[M]
with ScalaTestProbe[M]
with InternalRecipientRef[M] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ object ActorTestKit {
* Config loaded from the provided actor if that exists, otherwise
* using default configuration from the reference.conf resources that ship with the Akka libraries.
*/
def create(system: ActorSystem[_]): ActorTestKit =
def create(system: ActorSystem[?]): ActorTestKit =
new ActorTestKit(scaladsl.ActorTestKit(system))

/**
Expand Down Expand Up @@ -122,7 +122,7 @@ object ActorTestKit {
* an error is printed to stdout when the system did not shutdown but
* no exception is thrown.
*/
def shutdown(system: ActorSystem[_], duration: Duration, throwIfShutdownTimesOut: Boolean): Unit = {
def shutdown(system: ActorSystem[?], duration: Duration, throwIfShutdownTimesOut: Boolean): Unit = {
TestKitUtils.shutdown(system, duration.asScala, throwIfShutdownTimesOut)
}

Expand All @@ -131,7 +131,7 @@ object ActorTestKit {
* if more time than `system-shutdown-default` passes an exception is thrown
* (can be configured with `throw-on-shutdown-timeout`).
*/
def shutdown(system: ActorSystem[_], duration: Duration): Unit = {
def shutdown(system: ActorSystem[?], duration: Duration): Unit = {
val settings = TestKitSettings.create(system)
shutdown(system, duration, settings.ThrowOnShutdownTimeout)
}
Expand All @@ -141,7 +141,7 @@ object ActorTestKit {
* if more time than `system-shutdown-default` passes an exception is thrown
* (can be configured with `throw-on-shutdown-timeout`).
*/
def shutdown(system: ActorSystem[_]): Unit = {
def shutdown(system: ActorSystem[?]): Unit = {
val settings = TestKitSettings.create(system)
shutdown(system, settings.DefaultActorSystemShutdownTimeout.asJava, settings.ThrowOnShutdownTimeout)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import pekko.actor.typed.ActorSystem

final class JUnit5TestKitBuilder() {

var system: Option[ActorSystem[_]] = None
var system: Option[ActorSystem[?]] = None

var customConfig: Config = ApplicationTestConfig

var name: String = TestKitUtils.testNameFromCallStack(classOf[JUnit5TestKitBuilder])

def withSystem(system: ActorSystem[_]): JUnit5TestKitBuilder = {
def withSystem(system: ActorSystem[?]): JUnit5TestKitBuilder = {
this.system = Some(system)
this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ import pekko.annotation.DoNotInherit
* Matching events with an included `throwable` that is a class or subclass of the given
* `Throwable` class.
*/
def withCause(newCause: Class[_ <: Throwable]): LoggingTestKit
def withCause(newCause: Class[? <: Throwable]): LoggingTestKit

/**
* Matching events with MDC containing all entries of the given `Map`.
Expand Down Expand Up @@ -109,7 +109,7 @@ import pekko.annotation.DoNotInherit
*
* Care is taken to remove the testkit when the block is finished or aborted.
*/
def expect[T](system: ActorSystem[_], code: Supplier[T]): T
def expect[T](system: ActorSystem[?], code: Supplier[T]): T

}

Expand Down Expand Up @@ -198,7 +198,7 @@ object LoggingTestKit {
*
* More conditions can be added to the returned [LoggingEventFilter].
*/
def error(causeClass: Class[_ <: Throwable]): LoggingTestKit =
def error(causeClass: Class[? <: Throwable]): LoggingTestKit =
empty.withLogLevel(Level.ERROR).withCause(causeClass)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ final class ManualTime(delegate: pekko.testkit.ExplicitlyTriggeredScheduler) {
def timePasses(amount: Duration): Unit = delegate.timePasses(amount.asScala)

@varargs
def expectNoMessageFor(duration: Duration, on: TestProbe[_]*): Unit = {
def expectNoMessageFor(duration: Duration, on: TestProbe[?]*): Unit = {
delegate.timePasses(duration.asScala)
on.foreach(_.expectNoMessage(Duration.ZERO))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import pekko.actor.typed.ActorSystem
/**
* Utilities to test serialization.
*/
class SerializationTestKit(system: ActorSystem[_]) {
class SerializationTestKit(system: ActorSystem[?]) {

private val delegate = new scaladsl.SerializationTestKit(system)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ final class TestKitJunitResource(_kit: ActorTestKit) extends ExternalResource {
/**
* Use a custom [[pekko.actor.typed.ActorSystem]] for the actor system.
*/
def this(system: ActorSystem[_]) = this(ActorTestKit.create(system))
def this(system: ActorSystem[?]) = this(ActorTestKit.create(system))

/**
* Use a custom config for the actor system.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ object FishingOutcomes {

object TestProbe {

def create[M](system: ActorSystem[_]): TestProbe[M] =
def create[M](system: ActorSystem[?]): TestProbe[M] =
create(name = "testProbe", system)

def create[M](@unused clazz: Class[M], system: ActorSystem[_]): TestProbe[M] =
def create[M](@unused clazz: Class[M], system: ActorSystem[?]): TestProbe[M] =
create(system)

def create[M](name: String, system: ActorSystem[_]): TestProbe[M] =
def create[M](name: String, system: ActorSystem[?]): TestProbe[M] =
new TestProbeImpl[M](name, system)

def create[M](name: String, @unused clazz: Class[M], system: ActorSystem[_]): TestProbe[M] =
def create[M](name: String, @unused clazz: Class[M], system: ActorSystem[?]): TestProbe[M] =
new TestProbeImpl[M](name, system)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ object ActorTestKit {
* Config loaded from the provided actor if that exists, otherwise
* using default configuration from the reference.conf resources that ship with the Akka libraries.
*/
def apply(system: ActorSystem[_]): ActorTestKit = {
def apply(system: ActorSystem[?]): ActorTestKit = {
val name = testKitGuardianCounter.incrementAndGet() match {
case 1 => "test"
case n => s"test-$n"
Expand Down Expand Up @@ -159,7 +159,7 @@ object ActorTestKit {
* Shutdown the given [[pekko.actor.typed.ActorSystem]] and block until it shuts down,
* if more time than `TestKitSettings.DefaultActorSystemShutdownTimeout` passes an exception is thrown
*/
def shutdown(system: ActorSystem[_]): Unit = {
def shutdown(system: ActorSystem[?]): Unit = {
val settings = TestKitSettings(system)
TestKitUtils.shutdown(system, settings.DefaultActorSystemShutdownTimeout, settings.ThrowOnShutdownTimeout)
}
Expand All @@ -168,7 +168,7 @@ object ActorTestKit {
* Shutdown the given [[pekko.actor.typed.ActorSystem]] and block until it shuts down
* or the `duration` hits. If the timeout hits `verifySystemShutdown` decides
*/
def shutdown(system: ActorSystem[_], timeout: Duration, throwIfShutdownFails: Boolean = false): Unit =
def shutdown(system: ActorSystem[?], timeout: Duration, throwIfShutdownFails: Boolean = false): Unit =
TestKitUtils.shutdown(system, timeout, throwIfShutdownFails)

/**
Expand All @@ -192,7 +192,7 @@ object ActorTestKit {
* For synchronous testing of a `Behavior` see [[BehaviorTestKit]]
*/
final class ActorTestKit private[pekko] (
val internalSystem: ActorSystem[_],
val internalSystem: ActorSystem[?],
internalTestKitGuardian: ActorRef[ActorTestKitGuardian.TestKitCommand],
settings: Option[TestKitSettings]) {

Expand Down
Loading
Loading