From 0100fbbfade87205c64225ea79d24589f3837fae Mon Sep 17 00:00:00 2001 From: scala-steward Date: Wed, 15 Jan 2025 15:36:23 +0000 Subject: [PATCH 1/3] Update scalafmt-core to 3.8.4 --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 5b00db6..152270b 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = 3.8.3 +version = 3.8.4 maxColumn = 120 runner.dialect = scala213 fileOverride { From f02d45a6f6abeed0724ab0224e05437fc58cbd56 Mon Sep 17 00:00:00 2001 From: scala-steward Date: Wed, 15 Jan 2025 15:36:29 +0000 Subject: [PATCH 2/3] Reformat with scalafmt 3.8.4 Executed command: scalafmt --non-interactive --- .../play24/AppApplicationLoader.scala | 13 ++- .../app/com/softwaremill/play24/Seed.scala | 18 ++-- .../play24/controllers/CoffeeController.scala | 5 +- .../controllers/SupplierController.scala | 5 +- .../softwaremill/play24/models/Coffee.scala | 15 ++-- .../softwaremill/play24/models/Supplier.scala | 14 +-- .../controllers/CoffeeControllerSpec.scala | 7 +- .../controllers/ControllerContext.scala | 11 ++- .../softwaremill/play24/it/CoffeeSpec.scala | 4 +- .../play24/it/IntegrationContext.scala | 7 +- .../softwaremill/play24/it/SupplierSpec.scala | 4 +- examples/scalajs/build.sbt | 2 +- examples/scalajs/project/plugins.sbt | 2 +- .../softwaremill/MacwireScalajsExample.scala | 2 +- .../examples/scalatra/logic/Service2.scala | 20 ++--- .../examples/scalatra/servlet/Servlet1.scala | 8 +- .../scalatra/util/TimingInterceptor.scala | 2 +- .../macwire/WireWithCodeGen.scala | 2 +- .../macwire/WireWithCodeGen.scala | 6 +- .../akkasupport/AfterAllTerminate.scala | 15 ++-- .../macwire/akkasupport/CompileTests.scala | 86 ++++++++++++++----- .../macwire/akkasupport/demo/Demo.scala | 32 +++---- .../internals/CatsProvidersGraphContext.scala | 2 +- .../macwire/autocats/CompileTests.scala | 37 ++++++-- .../pekkosupport/AfterAllTerminate.scala | 15 ++-- .../macwire/pekkosupport/CompileTests.scala | 86 ++++++++++++++----- .../macwire/pekkosupport/demo/Demo.scala | 32 +++---- .../macwire/aop/ProxyingInterceptorTest.scala | 10 +-- .../macwire/scopes/ThreadLocalScopeTest.scala | 12 +-- .../softwaremill/macwire/CompileTests.scala | 27 ++++-- .../softwaremill/macwire/CompileTests.scala | 29 +++++-- .../two_modules_and_scope/SomeModule.scala | 2 - .../softwaremill/macwire/CompileTests.scala | 3 +- .../softwaremill/macwire/CompileTests.scala | 5 +- .../com/softwaremill/macwire/WiredTest.scala | 34 ++++---- 35 files changed, 358 insertions(+), 216 deletions(-) diff --git a/examples/play24/app/com/softwaremill/play24/AppApplicationLoader.scala b/examples/play24/app/com/softwaremill/play24/AppApplicationLoader.scala index a579063..21855ed 100644 --- a/examples/play24/app/com/softwaremill/play24/AppApplicationLoader.scala +++ b/examples/play24/app/com/softwaremill/play24/AppApplicationLoader.scala @@ -24,12 +24,12 @@ class AppApplicationLoader extends ApplicationLoader { } trait AppComponents -extends BuiltInComponents -with NingWSComponents // for wsClient -with DatabaseModule // Database injection -with DaoModule -with ControllerModule // Application controllers -{ + extends BuiltInComponents + with NingWSComponents // for wsClient + with DatabaseModule // Database injection + with DaoModule + with ControllerModule // Application controllers + { implicit val ec: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global lazy val assets: Assets = wire[Assets] @@ -48,4 +48,3 @@ with ControllerModule // Application controllers } class Z(as: ActorSystem) - diff --git a/examples/play24/app/com/softwaremill/play24/Seed.scala b/examples/play24/app/com/softwaremill/play24/Seed.scala index daadfc3..2aa303e 100644 --- a/examples/play24/app/com/softwaremill/play24/Seed.scala +++ b/examples/play24/app/com/softwaremill/play24/Seed.scala @@ -10,9 +10,9 @@ import scala.concurrent.duration._ import scala.language.postfixOps class Seed( - val dbConfig: DatabaseConfig[JdbcProfile], - val coffeeDao: CoffeeDao, - val supplierDao: SupplierDao + val dbConfig: DatabaseConfig[JdbcProfile], + val coffeeDao: CoffeeDao, + val supplierDao: SupplierDao ) { import dbConfig.driver.api._ @@ -26,17 +26,17 @@ class Seed( // Insert some suppliers supplierDao.query += Supplier(101, "Acme, Inc.", "99 Market Street", "Groundsville", "CA", "95199"), - supplierDao.query += Supplier( 49, "Superior Coffee", "1 Party Place", "Mendocino", "CA", "95460"), - supplierDao.query += Supplier(150, "The High Ground", "100 Coffee Lane", "Meadows", "CA", "93966"), + supplierDao.query += Supplier(49, "Superior Coffee", "1 Party Place", "Mendocino", "CA", "95460"), + supplierDao.query += Supplier(150, "The High Ground", "100 Coffee Lane", "Meadows", "CA", "93966"), // Equivalent SQL code: // insert into SUPPLIERS(SUP_ID, SUP_NAME, STREET, CITY, STATE, ZIP) values (?,?,?,?,?,?) // Insert some coffees (using JDBC's batch insert feature, if supported by the DB) coffeeDao.query ++= Seq( - Coffee("Colombian", 101, 7.99, 0, 0), - Coffee("French_Roast", 49, 8.99, 0, 0), - Coffee("Espresso", 150, 9.99, 0, 0), - Coffee("Colombian_Decaf", 101, 8.99, 0, 0), + Coffee("Colombian", 101, 7.99, 0, 0), + Coffee("French_Roast", 49, 8.99, 0, 0), + Coffee("Espresso", 150, 9.99, 0, 0), + Coffee("Colombian_Decaf", 101, 8.99, 0, 0), Coffee("French_Roast_Decaf", 49, 9.99, 0, 0) ) // Equivalent SQL code: diff --git a/examples/play24/app/com/softwaremill/play24/controllers/CoffeeController.scala b/examples/play24/app/com/softwaremill/play24/controllers/CoffeeController.scala index b4c2c0f..b3dd39c 100644 --- a/examples/play24/app/com/softwaremill/play24/controllers/CoffeeController.scala +++ b/examples/play24/app/com/softwaremill/play24/controllers/CoffeeController.scala @@ -7,8 +7,9 @@ import play.api.mvc.{Action, Controller} import scala.concurrent.ExecutionContext class CoffeeController( - coffeeDao: CoffeeDao -)(implicit ec: ExecutionContext) extends Controller { + coffeeDao: CoffeeDao +)(implicit ec: ExecutionContext) + extends Controller { def fetchAll() = Action.async { request => coffeeDao.all.map { coffees => diff --git a/examples/play24/app/com/softwaremill/play24/controllers/SupplierController.scala b/examples/play24/app/com/softwaremill/play24/controllers/SupplierController.scala index 5dac51d..d23d941 100644 --- a/examples/play24/app/com/softwaremill/play24/controllers/SupplierController.scala +++ b/examples/play24/app/com/softwaremill/play24/controllers/SupplierController.scala @@ -7,8 +7,9 @@ import play.api.mvc.{Action, Controller} import scala.concurrent.ExecutionContext class SupplierController( - supplierDao: SupplierDao -)(implicit ec: ExecutionContext) extends Controller { + supplierDao: SupplierDao +)(implicit ec: ExecutionContext) + extends Controller { def fetchAll() = Action.async { request => supplierDao.all.map { suppliers => diff --git a/examples/play24/app/com/softwaremill/play24/models/Coffee.scala b/examples/play24/app/com/softwaremill/play24/models/Coffee.scala index 7e025b5..5629c10 100644 --- a/examples/play24/app/com/softwaremill/play24/models/Coffee.scala +++ b/examples/play24/app/com/softwaremill/play24/models/Coffee.scala @@ -3,19 +3,18 @@ package com.softwaremill.play24.models import play.api.libs.json.Json import slick.driver.H2Driver.api._ -case class Coffee ( - name: String, - supId: Int, - price: Double, - sales: Int, - total: Int +case class Coffee( + name: String, + supId: Int, + price: Double, + sales: Int, + total: Int ) object Coffee { implicit val format = Json.format[Coffee] } - class CoffeeTable(tag: Tag) extends Table[Coffee](tag, "COFFEES") { def name = column[String]("COF_NAME", O.PrimaryKey) def supID = column[Int]("SUP_ID") @@ -25,4 +24,4 @@ class CoffeeTable(tag: Tag) extends Table[Coffee](tag, "COFFEES") { def * = (name, supID, price, sales, total) <> ((Coffee.apply _).tupled, Coffee.unapply) // A reified foreign key relation that can be navigated to create a join def supplier = foreignKey("SUP_FK", supID, TableQuery[SupplierTable])(_.id) -} \ No newline at end of file +} diff --git a/examples/play24/app/com/softwaremill/play24/models/Supplier.scala b/examples/play24/app/com/softwaremill/play24/models/Supplier.scala index 77958cd..0205aea 100644 --- a/examples/play24/app/com/softwaremill/play24/models/Supplier.scala +++ b/examples/play24/app/com/softwaremill/play24/models/Supplier.scala @@ -4,12 +4,12 @@ import play.api.libs.json.Json import slick.driver.H2Driver.api._ case class Supplier( - id: Int, - name: String, - street: String, - city: String, - state: String, - zip: String + id: Int, + name: String, + street: String, + city: String, + state: String, + zip: String ) object Supplier { @@ -24,5 +24,5 @@ class SupplierTable(tag: Tag) extends Table[Supplier](tag, "SUPPLIERS") { def state = column[String]("STATE") def zip = column[String]("ZIP") // Every table needs a * projection with the same type as the table's type parameter - def * = (id, name, street, city, state, zip) <> ((Supplier.apply _).tupled, Supplier.unapply) + def * = (id, name, street, city, state, zip) <> ((Supplier.apply _).tupled, Supplier.unapply) } diff --git a/examples/play24/test/com/softwaremill/play24/controllers/CoffeeControllerSpec.scala b/examples/play24/test/com/softwaremill/play24/controllers/CoffeeControllerSpec.scala index f5459be..99260fe 100644 --- a/examples/play24/test/com/softwaremill/play24/controllers/CoffeeControllerSpec.scala +++ b/examples/play24/test/com/softwaremill/play24/controllers/CoffeeControllerSpec.scala @@ -8,10 +8,9 @@ import play.api.test.Helpers._ import scala.concurrent.Future -/** - * Spec for testing controller logic, independent of external dependencies. Since our controllers don't really have any - * logic, just testing the output - */ +/** Spec for testing controller logic, independent of external dependencies. Since our controllers don't really have any + * logic, just testing the output + */ class CoffeeControllerSpec extends Specification { "Coffee Controller" should { "return all" in new ControllerContext { diff --git a/examples/play24/test/com/softwaremill/play24/controllers/ControllerContext.scala b/examples/play24/test/com/softwaremill/play24/controllers/ControllerContext.scala index 0088cd0..19036a2 100644 --- a/examples/play24/test/com/softwaremill/play24/controllers/ControllerContext.scala +++ b/examples/play24/test/com/softwaremill/play24/controllers/ControllerContext.scala @@ -7,11 +7,10 @@ import org.specs2.specification.Scope import scala.concurrent.ExecutionContext trait ControllerContext - extends ControllerModule - with MockDaoModule - with MockWsClient - with Scope - with MustThrownExpectations -{ + extends ControllerModule + with MockDaoModule + with MockWsClient + with Scope + with MustThrownExpectations { implicit val ec: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global } diff --git a/examples/play24/test/com/softwaremill/play24/it/CoffeeSpec.scala b/examples/play24/test/com/softwaremill/play24/it/CoffeeSpec.scala index 480400e..e0ac483 100644 --- a/examples/play24/test/com/softwaremill/play24/it/CoffeeSpec.scala +++ b/examples/play24/test/com/softwaremill/play24/it/CoffeeSpec.scala @@ -9,7 +9,7 @@ class CoffeeSpec extends PlaySpecification { println(status(response.get)) - response must beSome.which (status(_) == OK) + response must beSome.which(status(_) == OK) } } @@ -17,7 +17,7 @@ class CoffeeSpec extends PlaySpecification { "return priced coffees" in new IntegrationContext { val response = route(FakeRequest(GET, "/coffee/priced/9")) - response must beSome.which (status(_) == OK) + response must beSome.which(status(_) == OK) } } } diff --git a/examples/play24/test/com/softwaremill/play24/it/IntegrationContext.scala b/examples/play24/test/com/softwaremill/play24/it/IntegrationContext.scala index ae0908e..e77064c 100644 --- a/examples/play24/test/com/softwaremill/play24/it/IntegrationContext.scala +++ b/examples/play24/test/com/softwaremill/play24/it/IntegrationContext.scala @@ -3,6 +3,7 @@ package com.softwaremill.play24.it import com.softwaremill.play24.AppApplicationLoader import play.api.test.WithApplicationLoader -class IntegrationContext extends WithApplicationLoader( - applicationLoader = new AppApplicationLoader -) +class IntegrationContext + extends WithApplicationLoader( + applicationLoader = new AppApplicationLoader + ) diff --git a/examples/play24/test/com/softwaremill/play24/it/SupplierSpec.scala b/examples/play24/test/com/softwaremill/play24/it/SupplierSpec.scala index 67a38c4..8ea6813 100644 --- a/examples/play24/test/com/softwaremill/play24/it/SupplierSpec.scala +++ b/examples/play24/test/com/softwaremill/play24/it/SupplierSpec.scala @@ -1,5 +1,3 @@ package com.softwaremill.play24.it -class SupplierSpec { - -} +class SupplierSpec {} diff --git a/examples/scalajs/build.sbt b/examples/scalajs/build.sbt index 30a2e6d..de0f02b 100644 --- a/examples/scalajs/build.sbt +++ b/examples/scalajs/build.sbt @@ -6,4 +6,4 @@ scalaVersion := "2.11.7" libraryDependencies += "com.softwaremill.macwire" %% "macros" % "2.2.0" -libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "0.8.2" \ No newline at end of file +libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "0.8.2" diff --git a/examples/scalajs/project/plugins.sbt b/examples/scalajs/project/plugins.sbt index 1795db5..b27faaa 100644 --- a/examples/scalajs/project/plugins.sbt +++ b/examples/scalajs/project/plugins.sbt @@ -1 +1 @@ -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.5") \ No newline at end of file +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.5") diff --git a/examples/scalajs/src/main/scala/com/softwaremill/MacwireScalajsExample.scala b/examples/scalajs/src/main/scala/com/softwaremill/MacwireScalajsExample.scala index 8bd1be8..08e2266 100644 --- a/examples/scalajs/src/main/scala/com/softwaremill/MacwireScalajsExample.scala +++ b/examples/scalajs/src/main/scala/com/softwaremill/MacwireScalajsExample.scala @@ -21,4 +21,4 @@ object MacwireScalajsExample extends JSApp with MainModule { } override def main() {} -} \ No newline at end of file +} diff --git a/examples/scalatra/src/main/scala/com/softwaremill/macwire/examples/scalatra/logic/Service2.scala b/examples/scalatra/src/main/scala/com/softwaremill/macwire/examples/scalatra/logic/Service2.scala index f43a60d..ff7fb43 100644 --- a/examples/scalatra/src/main/scala/com/softwaremill/macwire/examples/scalatra/logic/Service2.scala +++ b/examples/scalatra/src/main/scala/com/softwaremill/macwire/examples/scalatra/logic/Service2.scala @@ -1,13 +1,11 @@ package com.softwaremill.macwire.examples.scalatra.logic -class Service2(submittedData: SubmittedData, - service3: Service3, - loggedInUser: LoggedInUser) { - def fetchStatus = { - Thread.sleep(20L) - s"This is Service2. " + - s"Logged in user: ${loggedInUser.username}, " + - s"submitted data: ${submittedData.data}, " + - s"service 3: ${service3.fetchStatus}" - } - } +class Service2(submittedData: SubmittedData, service3: Service3, loggedInUser: LoggedInUser) { + def fetchStatus = { + Thread.sleep(20L) + s"This is Service2. " + + s"Logged in user: ${loggedInUser.username}, " + + s"submitted data: ${submittedData.data}, " + + s"service 3: ${service3.fetchStatus}" + } +} diff --git a/examples/scalatra/src/main/scala/com/softwaremill/macwire/examples/scalatra/servlet/Servlet1.scala b/examples/scalatra/src/main/scala/com/softwaremill/macwire/examples/scalatra/servlet/Servlet1.scala index 2367ff4..522b4de 100644 --- a/examples/scalatra/src/main/scala/com/softwaremill/macwire/examples/scalatra/servlet/Servlet1.scala +++ b/examples/scalatra/src/main/scala/com/softwaremill/macwire/examples/scalatra/servlet/Servlet1.scala @@ -4,12 +4,12 @@ import org.scalatra.ScalatraServlet import org.scalatra.scalate.ScalateSupport import com.softwaremill.macwire.examples.scalatra.logic.{SubmittedData, Service2, Service1} -class Servlet1(service1: Service1, service2: Service2, submittedData: SubmittedData) extends ScalatraServlet with ScalateSupport { +class Servlet1(service1: Service1, service2: Service2, submittedData: SubmittedData) + extends ScalatraServlet + with ScalateSupport { get("/") { submittedData.data = params.getOrElse("data", null) contentType = "text/html" - ssp("index", - "service1status" -> service1.fetchStatus, - "service2status" -> service2.fetchStatus) + ssp("index", "service1status" -> service1.fetchStatus, "service2status" -> service2.fetchStatus) } } diff --git a/examples/scalatra/src/main/scala/com/softwaremill/macwire/examples/scalatra/util/TimingInterceptor.scala b/examples/scalatra/src/main/scala/com/softwaremill/macwire/examples/scalatra/util/TimingInterceptor.scala index 92454b6..e1b5076 100644 --- a/examples/scalatra/src/main/scala/com/softwaremill/macwire/examples/scalatra/util/TimingInterceptor.scala +++ b/examples/scalatra/src/main/scala/com/softwaremill/macwire/examples/scalatra/util/TimingInterceptor.scala @@ -11,7 +11,7 @@ object TimingInterceptor extends ProxyingInterceptor { ctx.proceed() } finally { val end = System.currentTimeMillis() - println(s"Invocation of $classWithMethodName took: ${end-start}ms") + println(s"Invocation of $classWithMethodName took: ${end - start}ms") } } } diff --git a/macros/src/test/scala-2/com/softwaremill/macwire/WireWithCodeGen.scala b/macros/src/test/scala-2/com/softwaremill/macwire/WireWithCodeGen.scala index b370986..683f09d 100644 --- a/macros/src/test/scala-2/com/softwaremill/macwire/WireWithCodeGen.scala +++ b/macros/src/test/scala-2/com/softwaremill/macwire/WireWithCodeGen.scala @@ -3,7 +3,7 @@ package com.softwaremill.macwire object WireWithCodeGen { def main(args: Array[String]) = { - for(idx <- 0 until 22) { + for (idx <- 0 until 22) { val tpes = (0 to idx).map(i => ('A' + i).toChar).mkString(",") println(s"def wireWith[$tpes,RES](factory: ($tpes) => RES): RES = macro MacwireMacros.wireWith_impl[RES]") } diff --git a/macros/src/test/scala-3/com/softwaremill/macwire/WireWithCodeGen.scala b/macros/src/test/scala-3/com/softwaremill/macwire/WireWithCodeGen.scala index cc78409..2b95c04 100644 --- a/macros/src/test/scala-3/com/softwaremill/macwire/WireWithCodeGen.scala +++ b/macros/src/test/scala-3/com/softwaremill/macwire/WireWithCodeGen.scala @@ -3,9 +3,11 @@ package com.softwaremill.macwire object WireWithCodeGen { def main(args: Array[String]) = { - for(idx <- 0 until 22) { + for (idx <- 0 until 22) { val tpes = (0 to idx).map(i => ('A' + i).toChar).mkString(",") - println(s"inline def wireWith[$tpes,RES](inline factory: ($tpes) => RES): RES = $${ MacwireMacros.wireWith_impl[RES]('factory) }") + println( + s"inline def wireWith[$tpes,RES](inline factory: ($tpes) => RES): RES = $${ MacwireMacros.wireWith_impl[RES]('factory) }" + ) } } } diff --git a/macrosAkkaTests/src/test/scala/com/softwaremill/macwire/akkasupport/AfterAllTerminate.scala b/macrosAkkaTests/src/test/scala/com/softwaremill/macwire/akkasupport/AfterAllTerminate.scala index c1ae993..bdbf1fb 100644 --- a/macrosAkkaTests/src/test/scala/com/softwaremill/macwire/akkasupport/AfterAllTerminate.scala +++ b/macrosAkkaTests/src/test/scala/com/softwaremill/macwire/akkasupport/AfterAllTerminate.scala @@ -7,22 +7,21 @@ import scala.concurrent.duration._ object AfterAllTerminate { - /** - * We need to terminate ActorSystem. - * It can be done in test script in last line by simply calling `system.terminate()`. - * However above solution can terminate the `actorSystem` sooner than all messages are being delivered. - * That will result in ugly messages in test logs which are not related to bugs: + /** We need to terminate ActorSystem. It can be done in test script in last line by simply calling + * `system.terminate()`. However above solution can terminate the `actorSystem` sooner than all messages are being + * delivered. That will result in ugly messages in test logs which are not related to bugs: * * {{{[INFO] [01/31/2017 19:33:21.407] [wireProps-9-subtypeDependencyInScope-akka.actor.default-dispatcher-6] [akka://wireProps-9-subtypeDependencyInScope/user/someActor] Message [java.lang.String] from Actor[akka://wireProps-9-subtypeDependencyInScope/deadLetters] to Actor[akka://wireProps-9-subtypeDependencyInScope/user/someActor#-2046131540] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.[info] wireActor-11-toManyInjectAnnotations.failure}}} * - * If we terminate `ActorSystem` using this hook the system will be terminated after all messages - * are being delivered. Logs become cleaner. + * If we terminate `ActorSystem` using this hook the system will be terminated after all messages are being + * delivered. Logs become cleaner. */ def apply(system: ActorSystem): Unit = Runtime.getRuntime.addShutdownHook( MonitorableThreadFactory( name = "monitoring-thread-factory", daemonic = false, - contextClassLoader = Some(Thread.currentThread().getContextClassLoader)).newThread(new Runnable { + contextClassLoader = Some(Thread.currentThread().getContextClassLoader) + ).newThread(new Runnable { override def run(): Unit = { val terminate = system.terminate() Await.result(terminate, 10.seconds) diff --git a/macrosAkkaTests/src/test/scala/com/softwaremill/macwire/akkasupport/CompileTests.scala b/macrosAkkaTests/src/test/scala/com/softwaremill/macwire/akkasupport/CompileTests.scala index f62dba2..0428edc 100644 --- a/macrosAkkaTests/src/test/scala/com/softwaremill/macwire/akkasupport/CompileTests.scala +++ b/macrosAkkaTests/src/test/scala/com/softwaremill/macwire/akkasupport/CompileTests.scala @@ -9,17 +9,33 @@ class CompileTests extends CompileTestsSupport { "wireProps-3-missingDependency" -> List("Cannot find a value of type: [A]"), "wireAnonymousActor-3-missingDependency" -> List("Cannot find a value of type: [A]"), "wireActor-3-missingDependency" -> List("Cannot find a value of type: [A]"), - "wireAnonymousActor-3.1-missingActorRefFactoryDependency" -> List("Cannot find a value of type: [akka.actor.ActorRefFactory]"), - "wireActor-3.1-missingActorRefFactoryDependency" -> List("Cannot find a value of type: [akka.actor.ActorRefFactory]"), + "wireAnonymousActor-3.1-missingActorRefFactoryDependency" -> List( + "Cannot find a value of type: [akka.actor.ActorRefFactory]" + ), + "wireActor-3.1-missingActorRefFactoryDependency" -> List( + "Cannot find a value of type: [akka.actor.ActorRefFactory]" + ), "wireProps-6-injectAnnotationButNoDependencyInScope" -> List("Cannot find a value of type: [C]"), "wireAnonymousActor-6-injectAnnotationButNoDependencyInScope" -> List("Cannot find a value of type: [C]"), "wireActor-6-injectAnnotationButNoDependencyInScope" -> List("Cannot find a value of type: [C]"), - "wireProps-7-notActor" -> List("type arguments [NotActor] do not conform to macro method wireProps's type parameter bounds [T <: akka.actor.Actor]"), - "wireAnonymousActor-7-notActor" -> List("type arguments [NotActor] do not conform to macro method wireAnonymousActor's type parameter bounds [T <: akka.actor.Actor]"), - "wireActor-7-notActor" -> List("type arguments [NotActor] do not conform to macro method wireActor's type parameter bounds [T <: akka.actor.Actor]"), - "wireProps-11-toManyInjectAnnotations" -> List("Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActor]"), - "wireAnonymousActor-11-toManyInjectAnnotations" -> List("Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActor]"), - "wireActor-11-toManyInjectAnnotations" -> List("Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActor]"), + "wireProps-7-notActor" -> List( + "type arguments [NotActor] do not conform to macro method wireProps's type parameter bounds [T <: akka.actor.Actor]" + ), + "wireAnonymousActor-7-notActor" -> List( + "type arguments [NotActor] do not conform to macro method wireAnonymousActor's type parameter bounds [T <: akka.actor.Actor]" + ), + "wireActor-7-notActor" -> List( + "type arguments [NotActor] do not conform to macro method wireActor's type parameter bounds [T <: akka.actor.Actor]" + ), + "wireProps-11-toManyInjectAnnotations" -> List( + "Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActor]" + ), + "wireAnonymousActor-11-toManyInjectAnnotations" -> List( + "Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActor]" + ), + "wireActor-11-toManyInjectAnnotations" -> List( + "Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActor]" + ), "wireProps-12-noPublicConstructor" -> List("Cannot find a public constructor for [SomeActor]"), "wireAnonymousActor-12-noPublicConstructor" -> List("Cannot find a public constructor for [SomeActor]"), "wireActor-12-noPublicConstructor" -> List("Cannot find a public constructor for [SomeActor]"), @@ -28,33 +44,63 @@ class CompileTests extends CompileTestsSupport { "wireProps-13-missingImplicitDependency" -> List("could not find implicit value for parameter e: D"), "wireActorWithFactory-2-manyParameterLists" -> List("Not supported factory type: "), "wireActorWithFactory-3-missingDependency" -> List("Cannot find a value of type: [A]"), - "wireActorWithFactory-7-notActorFactory" -> List("overloaded method", "apply with alternatives:", "cannot be applied to (NotActor)"), + "wireActorWithFactory-7-notActorFactory" -> List( + "overloaded method", + "apply with alternatives:", + "cannot be applied to (NotActor)" + ), "wireActorWithFactory-12-privateMethod" -> List("method get in object SomeActor cannot be accessed"), "wireActorWithProducer-3-missingDependency" -> List("Cannot find a value of type: [A]"), "wireActorWithProducer-6-injectAnnotationButNoDependencyInScope" -> List("Cannot find a value of type: [C]"), "wireActorWithProducer-7-notActorProducer" -> List("wireActorWith does not support the type: [NotProducer]"), - "wireActorWithProducer-11-toManyInjectAnnotations" -> List("Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActorProducer]"), - "wireActorWithProducer-12-noPublicConstructor" -> List("Cannot find a public constructor for [SomeActorProducer]"), + "wireActorWithProducer-11-toManyInjectAnnotations" -> List( + "Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActorProducer]" + ), + "wireActorWithProducer-12-noPublicConstructor" -> List( + "Cannot find a public constructor for [SomeActorProducer]" + ), "wireActorWithProducer-13-missingImplicitDependency" -> List("could not find implicit value for parameter e: D"), "wireAnonymousActorWithFactory-2-manyParameterLists" -> List("Not supported factory type: "), "wireAnonymousActorWithFactory-3-missingDependency" -> List("Cannot find a value of type: [A]"), - "wireAnonymousActorWithFactory-7-notActorFactory" -> List("overloaded method", "apply with alternatives:", "cannot be applied to (NotActor)"), + "wireAnonymousActorWithFactory-7-notActorFactory" -> List( + "overloaded method", + "apply with alternatives:", + "cannot be applied to (NotActor)" + ), "wireAnonymousActorWithFactory-12-privateMethod" -> List("method get in object SomeActor cannot be accessed"), "wireAnonymousActorWithProducer-3-missingDependency" -> List("Cannot find a value of type: [A]"), - "wireAnonymousActorWithProducer-6-injectAnnotationButNoDependencyInScope" -> List("Cannot find a value of type: [C]"), - "wireAnonymousActorWithProducer-7-notActorProducer" -> List("wireAnonymousActorWith does not support the type: [NotProducer]"), - "wireAnonymousActorWithProducer-11-toManyInjectAnnotations" -> List("Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActorProducer]"), - "wireAnonymousActorWithProducer-12-noPublicConstructor" -> List("Cannot find a public constructor for [SomeActorProducer]"), - "wireAnonymousActorWithProducer-13-missingImplicitDependency" -> List("could not find implicit value for parameter e: D"), + "wireAnonymousActorWithProducer-6-injectAnnotationButNoDependencyInScope" -> List( + "Cannot find a value of type: [C]" + ), + "wireAnonymousActorWithProducer-7-notActorProducer" -> List( + "wireAnonymousActorWith does not support the type: [NotProducer]" + ), + "wireAnonymousActorWithProducer-11-toManyInjectAnnotations" -> List( + "Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActorProducer]" + ), + "wireAnonymousActorWithProducer-12-noPublicConstructor" -> List( + "Cannot find a public constructor for [SomeActorProducer]" + ), + "wireAnonymousActorWithProducer-13-missingImplicitDependency" -> List( + "could not find implicit value for parameter e: D" + ), "wirePropsWithFactory-2-manyParameterLists" -> List("Not supported factory type: "), "wirePropsWithFactory-3-missingDependency" -> List("Cannot find a value of type: [A]"), - "wirePropsWithFactory-7-notActorFactory" -> List("overloaded method", "apply with alternatives:", "cannot be applied to (NotActor)"), + "wirePropsWithFactory-7-notActorFactory" -> List( + "overloaded method", + "apply with alternatives:", + "cannot be applied to (NotActor)" + ), "wirePropsWithFactory-12-privateMethod" -> List("method get in object SomeActor cannot be accessed"), "wirePropsWithProducer-3-missingDependency" -> List("Cannot find a value of type: [A]"), "wirePropsWithProducer-6-injectAnnotationButNoDependencyInScope" -> List("Cannot find a value of type: [C]"), "wirePropsWithProducer-7-notActorProducer" -> List("wirePropsWith does not support the type: [NotProducer]"), - "wirePropsWithProducer-11-toManyInjectAnnotations" -> List("Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActorProducer]"), - "wirePropsWithProducer-12-noPublicConstructor" -> List("Cannot find a public constructor for [SomeActorProducer]"), + "wirePropsWithProducer-11-toManyInjectAnnotations" -> List( + "Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActorProducer]" + ), + "wirePropsWithProducer-12-noPublicConstructor" -> List( + "Cannot find a public constructor for [SomeActorProducer]" + ), "wirePropsWithProducer-13-missingImplicitDependency" -> List("could not find implicit value for parameter e: D") ), expectedWarnings = List() diff --git a/macrosAkkaTests/src/test/scala/com/softwaremill/macwire/akkasupport/demo/Demo.scala b/macrosAkkaTests/src/test/scala/com/softwaremill/macwire/akkasupport/demo/Demo.scala index 650d75e..fa69f69 100644 --- a/macrosAkkaTests/src/test/scala/com/softwaremill/macwire/akkasupport/demo/Demo.scala +++ b/macrosAkkaTests/src/test/scala/com/softwaremill/macwire/akkasupport/demo/Demo.scala @@ -20,7 +20,8 @@ object Demo extends App { val bertaSinger = wireActor[SingerActor]("berta").taggedWith[Singer] val singers = wireSet[ActorRef @@ Singer] - val `4 voices polyphone` = system.actorOf(wireProps[PolyphoneActor].withRouter(RoundRobinPool(4))).taggedWith[Polyphone] + val `4 voices polyphone` = + system.actorOf(wireProps[PolyphoneActor].withRouter(RoundRobinPool(4))).taggedWith[Polyphone] val orchestra = wireAnonymousActor[OrchestraActor] @@ -33,45 +34,44 @@ object Demo extends App { system.terminate() } - trait Score case object Play case object PlaySoloPolyphone trait Polyphone class PolyphoneActor extends Actor { - override def receive: Receive = { - case Play => println(s"Polyphone ${self.path.name} is playing: uouiiiiiiiiiii") + override def receive: Receive = { case Play => + println(s"Polyphone ${self.path.name} is playing: uouiiiiiiiiiii") } } trait Violin class ViolinActor(score: Score) extends Actor { - override def receive: Receive = { - case Play => println("Violin is playing: uuuuuuu ...") + override def receive: Receive = { case Play => + println("Violin is playing: uuuuuuu ...") } } trait Guitar -class GuitarActor(score: Score) extends Actor { - override def receive: Receive = { - case Play => println("Guitar is playing: pa pa pppaaa ...") +class GuitarActor(score: Score) extends Actor { + override def receive: Receive = { case Play => + println("Guitar is playing: pa pa pppaaa ...") } } trait Singer class SingerActor(score: Score) extends Actor { - override def receive: Receive = { - case Play => println(s"${self.path.name} is singing: aaaaa uuuu eeee") + override def receive: Receive = { case Play => + println(s"${self.path.name} is singing: aaaaa uuuu eeee") } } trait Orchestra class OrchestraActor( - v: ActorRef @@ Violin, - g: ActorRef @@ Guitar, - polyphone: ActorRef @@ Polyphone, - choir: Set[ActorRef @@ Singer] + v: ActorRef @@ Violin, + g: ActorRef @@ Guitar, + polyphone: ActorRef @@ Polyphone, + choir: Set[ActorRef @@ Singer] ) extends Actor { val supportiveChoirScore = new Score {} @@ -87,6 +87,6 @@ class OrchestraActor( polyphone ! Play case PlaySoloPolyphone => polyphone ! Play - //...whatever + // ...whatever } } diff --git a/macrosAutoCats/src/main/scala/com/softwaremill/macwire/autocats/internals/CatsProvidersGraphContext.scala b/macrosAutoCats/src/main/scala/com/softwaremill/macwire/autocats/internals/CatsProvidersGraphContext.scala index 235a0fc..f2f3ccf 100644 --- a/macrosAutoCats/src/main/scala/com/softwaremill/macwire/autocats/internals/CatsProvidersGraphContext.scala +++ b/macrosAutoCats/src/main/scala/com/softwaremill/macwire/autocats/internals/CatsProvidersGraphContext.scala @@ -142,7 +142,7 @@ class CatsProvidersGraphContext[C <: blackbox.Context](val c: C, val log: Logger val resolvedFMContext = resolveFactoryMethods(initContext) /** We assume that we cannot use input provider directly, so we create a result object with available constructors. - * It's a mimic of `wire`'s property + * It's a mimic of `wire` 's property */ val (resolvedCtx, rootProvider) = maybeResolveWithFactoryMethod(resolvedFMContext)( diff --git a/macrosAutoCatsTests/src/test/scala/com/softwaremill/macwire/autocats/CompileTests.scala b/macrosAutoCatsTests/src/test/scala/com/softwaremill/macwire/autocats/CompileTests.scala index 440ea16..9cfc9da 100644 --- a/macrosAutoCatsTests/src/test/scala/com/softwaremill/macwire/autocats/CompileTests.scala +++ b/macrosAutoCatsTests/src/test/scala/com/softwaremill/macwire/autocats/CompileTests.scala @@ -6,16 +6,39 @@ class CompileTests extends CatsAutowireCompileTestsSupport { runTestsWith( expectedFailures = List( - "simpleMissingDeps" -> List("Failed to create an instance of [B].", "Missing dependency of type [String]. Path [constructor B].a -> [constructor A].s"), - "simpleMissingMultiLevelDeps" -> List("Failed to create an instance of [C].", "Missing dependency of type [String]. Path [constructor C].b -> [constructor B].a -> [constructor A].s"), + "simpleMissingDeps" -> List( + "Failed to create an instance of [B].", + "Missing dependency of type [String]. Path [constructor B].a -> [constructor A].s" + ), + "simpleMissingMultiLevelDeps" -> List( + "Failed to create an instance of [C].", + "Missing dependency of type [String]. Path [constructor C].b -> [constructor B].a -> [constructor A].s" + ), "notUsedProvider" -> List("Not used providers for the following types [D]"), "ambiguousInstances" -> List("Ambiguous instances of types [A]"), "ambiguousTraitImplementations" -> List("Ambiguous instances of types [A, B]"), - "constructInputProvider" -> List("Failed to create an instance of [B].", "Missing dependency of type [String]. Path [constructor B].a -> [constructor A].s"),//TODO we should add a warning in this case. - "missingConstructorDependencies" -> List("Failed to create an instance of [C].", "Missing dependency of type [Int]. Path [constructor C].b -> [constructor B].i"), - "missingMultipleConstructorDependencies" -> List("Failed to create an instance of [C].", "Missing dependency of type [Int]. Path [constructor C].b -> [constructor B].i", "Missing dependency of type [String]. Path [constructor C].s"), - "missingApplyDependencies" -> List("Failed to create an instance of [", "C].", "Missing dependency of type [Int]. Path [constructor C].b -> [method apply].i"), - "missingFactoryMethodDependencies" -> List("Failed to create an instance of [C].", "Missing dependency of type [Int]. Path [constructor C].b -> [method makeB].i"), + "constructInputProvider" -> List( + "Failed to create an instance of [B].", + "Missing dependency of type [String]. Path [constructor B].a -> [constructor A].s" + ), // TODO we should add a warning in this case. + "missingConstructorDependencies" -> List( + "Failed to create an instance of [C].", + "Missing dependency of type [Int]. Path [constructor C].b -> [constructor B].i" + ), + "missingMultipleConstructorDependencies" -> List( + "Failed to create an instance of [C].", + "Missing dependency of type [Int]. Path [constructor C].b -> [constructor B].i", + "Missing dependency of type [String]. Path [constructor C].s" + ), + "missingApplyDependencies" -> List( + "Failed to create an instance of [", + "C].", + "Missing dependency of type [Int]. Path [constructor C].b -> [method apply].i" + ), + "missingFactoryMethodDependencies" -> List( + "Failed to create an instance of [C].", + "Missing dependency of type [Int]. Path [constructor C].b -> [method makeB].i" + ) ), expectedWarnings = List() ) diff --git a/macrosPekkoTests/src/test/scala/com/softwaremill/macwire/pekkosupport/AfterAllTerminate.scala b/macrosPekkoTests/src/test/scala/com/softwaremill/macwire/pekkosupport/AfterAllTerminate.scala index 0e56e23..b87397b 100644 --- a/macrosPekkoTests/src/test/scala/com/softwaremill/macwire/pekkosupport/AfterAllTerminate.scala +++ b/macrosPekkoTests/src/test/scala/com/softwaremill/macwire/pekkosupport/AfterAllTerminate.scala @@ -7,22 +7,21 @@ import scala.concurrent.duration._ object AfterAllTerminate { - /** - * We need to terminate ActorSystem. - * It can be done in test script in last line by simply calling `system.terminate()`. - * However above solution can terminate the `actorSystem` sooner than all messages are being delivered. - * That will result in ugly messages in test logs which are not related to bugs: + /** We need to terminate ActorSystem. It can be done in test script in last line by simply calling + * `system.terminate()`. However above solution can terminate the `actorSystem` sooner than all messages are being + * delivered. That will result in ugly messages in test logs which are not related to bugs: * * {{{[INFO] [01/31/2017 19:33:21.407] [wireProps-9-subtypeDependencyInScope-org.apache.pekko.actor.default-dispatcher-6] [org.apache.pekko://wireProps-9-subtypeDependencyInScope/user/someActor] Message [java.lang.String] from Actor[org.apache.pekko://wireProps-9-subtypeDependencyInScope/deadLetters] to Actor[org.apache.pekko://wireProps-9-subtypeDependencyInScope/user/someActor#-2046131540] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'org.apache.pekko.log-dead-letters' and 'org.apache.pekko.log-dead-letters-during-shutdown'.[info] wireActor-11-toManyInjectAnnotations.failure}}} * - * If we terminate `ActorSystem` using this hook the system will be terminated after all messages - * are being delivered. Logs become cleaner. + * If we terminate `ActorSystem` using this hook the system will be terminated after all messages are being + * delivered. Logs become cleaner. */ def apply(system: ActorSystem): Unit = Runtime.getRuntime.addShutdownHook( MonitorableThreadFactory( name = "monitoring-thread-factory", daemonic = false, - contextClassLoader = Some(Thread.currentThread().getContextClassLoader)).newThread(new Runnable { + contextClassLoader = Some(Thread.currentThread().getContextClassLoader) + ).newThread(new Runnable { override def run(): Unit = { val terminate = system.terminate() Await.result(terminate, 10.seconds) diff --git a/macrosPekkoTests/src/test/scala/com/softwaremill/macwire/pekkosupport/CompileTests.scala b/macrosPekkoTests/src/test/scala/com/softwaremill/macwire/pekkosupport/CompileTests.scala index 721f34a..d77c680 100644 --- a/macrosPekkoTests/src/test/scala/com/softwaremill/macwire/pekkosupport/CompileTests.scala +++ b/macrosPekkoTests/src/test/scala/com/softwaremill/macwire/pekkosupport/CompileTests.scala @@ -9,17 +9,33 @@ class CompileTests extends CompileTestsSupport { "wireProps-3-missingDependency" -> List("Cannot find a value of type: [A]"), "wireAnonymousActor-3-missingDependency" -> List("Cannot find a value of type: [A]"), "wireActor-3-missingDependency" -> List("Cannot find a value of type: [A]"), - "wireAnonymousActor-3.1-missingActorRefFactoryDependency" -> List("Cannot find a value of type: [org.apache.pekko.actor.ActorRefFactory]"), - "wireActor-3.1-missingActorRefFactoryDependency" -> List("Cannot find a value of type: [org.apache.pekko.actor.ActorRefFactory]"), + "wireAnonymousActor-3.1-missingActorRefFactoryDependency" -> List( + "Cannot find a value of type: [org.apache.pekko.actor.ActorRefFactory]" + ), + "wireActor-3.1-missingActorRefFactoryDependency" -> List( + "Cannot find a value of type: [org.apache.pekko.actor.ActorRefFactory]" + ), "wireProps-6-injectAnnotationButNoDependencyInScope" -> List("Cannot find a value of type: [C]"), "wireAnonymousActor-6-injectAnnotationButNoDependencyInScope" -> List("Cannot find a value of type: [C]"), "wireActor-6-injectAnnotationButNoDependencyInScope" -> List("Cannot find a value of type: [C]"), - "wireProps-7-notActor" -> List("type arguments [NotActor] do not conform to macro method wireProps's type parameter bounds [T <: org.apache.pekko.actor.Actor]"), - "wireAnonymousActor-7-notActor" -> List("type arguments [NotActor] do not conform to macro method wireAnonymousActor's type parameter bounds [T <: org.apache.pekko.actor.Actor]"), - "wireActor-7-notActor" -> List("type arguments [NotActor] do not conform to macro method wireActor's type parameter bounds [T <: org.apache.pekko.actor.Actor]"), - "wireProps-11-toManyInjectAnnotations" -> List("Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActor]"), - "wireAnonymousActor-11-toManyInjectAnnotations" -> List("Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActor]"), - "wireActor-11-toManyInjectAnnotations" -> List("Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActor]"), + "wireProps-7-notActor" -> List( + "type arguments [NotActor] do not conform to macro method wireProps's type parameter bounds [T <: org.apache.pekko.actor.Actor]" + ), + "wireAnonymousActor-7-notActor" -> List( + "type arguments [NotActor] do not conform to macro method wireAnonymousActor's type parameter bounds [T <: org.apache.pekko.actor.Actor]" + ), + "wireActor-7-notActor" -> List( + "type arguments [NotActor] do not conform to macro method wireActor's type parameter bounds [T <: org.apache.pekko.actor.Actor]" + ), + "wireProps-11-toManyInjectAnnotations" -> List( + "Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActor]" + ), + "wireAnonymousActor-11-toManyInjectAnnotations" -> List( + "Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActor]" + ), + "wireActor-11-toManyInjectAnnotations" -> List( + "Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActor]" + ), "wireProps-12-noPublicConstructor" -> List("Cannot find a public constructor for [SomeActor]"), "wireAnonymousActor-12-noPublicConstructor" -> List("Cannot find a public constructor for [SomeActor]"), "wireActor-12-noPublicConstructor" -> List("Cannot find a public constructor for [SomeActor]"), @@ -28,33 +44,63 @@ class CompileTests extends CompileTestsSupport { "wireProps-13-missingImplicitDependency" -> List("could not find implicit value for parameter e: D"), "wireActorWithFactory-2-manyParameterLists" -> List("Not supported factory type: "), "wireActorWithFactory-3-missingDependency" -> List("Cannot find a value of type: [A]"), - "wireActorWithFactory-7-notActorFactory" -> List("overloaded method", "apply with alternatives:", "cannot be applied to (NotActor)"), + "wireActorWithFactory-7-notActorFactory" -> List( + "overloaded method", + "apply with alternatives:", + "cannot be applied to (NotActor)" + ), "wireActorWithFactory-12-privateMethod" -> List("method get in object SomeActor cannot be accessed"), "wireActorWithProducer-3-missingDependency" -> List("Cannot find a value of type: [A]"), "wireActorWithProducer-6-injectAnnotationButNoDependencyInScope" -> List("Cannot find a value of type: [C]"), "wireActorWithProducer-7-notActorProducer" -> List("wireActorWith does not support the type: [NotProducer]"), - "wireActorWithProducer-11-toManyInjectAnnotations" -> List("Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActorProducer]"), - "wireActorWithProducer-12-noPublicConstructor" -> List("Cannot find a public constructor for [SomeActorProducer]"), + "wireActorWithProducer-11-toManyInjectAnnotations" -> List( + "Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActorProducer]" + ), + "wireActorWithProducer-12-noPublicConstructor" -> List( + "Cannot find a public constructor for [SomeActorProducer]" + ), "wireActorWithProducer-13-missingImplicitDependency" -> List("could not find implicit value for parameter e: D"), "wireAnonymousActorWithFactory-2-manyParameterLists" -> List("Not supported factory type: "), "wireAnonymousActorWithFactory-3-missingDependency" -> List("Cannot find a value of type: [A]"), - "wireAnonymousActorWithFactory-7-notActorFactory" -> List("overloaded method", "apply with alternatives:", "cannot be applied to (NotActor)"), + "wireAnonymousActorWithFactory-7-notActorFactory" -> List( + "overloaded method", + "apply with alternatives:", + "cannot be applied to (NotActor)" + ), "wireAnonymousActorWithFactory-12-privateMethod" -> List("method get in object SomeActor cannot be accessed"), "wireAnonymousActorWithProducer-3-missingDependency" -> List("Cannot find a value of type: [A]"), - "wireAnonymousActorWithProducer-6-injectAnnotationButNoDependencyInScope" -> List("Cannot find a value of type: [C]"), - "wireAnonymousActorWithProducer-7-notActorProducer" -> List("wireAnonymousActorWith does not support the type: [NotProducer]"), - "wireAnonymousActorWithProducer-11-toManyInjectAnnotations" -> List("Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActorProducer]"), - "wireAnonymousActorWithProducer-12-noPublicConstructor" -> List("Cannot find a public constructor for [SomeActorProducer]"), - "wireAnonymousActorWithProducer-13-missingImplicitDependency" -> List("could not find implicit value for parameter e: D"), + "wireAnonymousActorWithProducer-6-injectAnnotationButNoDependencyInScope" -> List( + "Cannot find a value of type: [C]" + ), + "wireAnonymousActorWithProducer-7-notActorProducer" -> List( + "wireAnonymousActorWith does not support the type: [NotProducer]" + ), + "wireAnonymousActorWithProducer-11-toManyInjectAnnotations" -> List( + "Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActorProducer]" + ), + "wireAnonymousActorWithProducer-12-noPublicConstructor" -> List( + "Cannot find a public constructor for [SomeActorProducer]" + ), + "wireAnonymousActorWithProducer-13-missingImplicitDependency" -> List( + "could not find implicit value for parameter e: D" + ), "wirePropsWithFactory-2-manyParameterLists" -> List("Not supported factory type: "), "wirePropsWithFactory-3-missingDependency" -> List("Cannot find a value of type: [A]"), - "wirePropsWithFactory-7-notActorFactory" -> List("overloaded method", "apply with alternatives:", "cannot be applied to (NotActor)"), + "wirePropsWithFactory-7-notActorFactory" -> List( + "overloaded method", + "apply with alternatives:", + "cannot be applied to (NotActor)" + ), "wirePropsWithFactory-12-privateMethod" -> List("method get in object SomeActor cannot be accessed"), "wirePropsWithProducer-3-missingDependency" -> List("Cannot find a value of type: [A]"), "wirePropsWithProducer-6-injectAnnotationButNoDependencyInScope" -> List("Cannot find a value of type: [C]"), "wirePropsWithProducer-7-notActorProducer" -> List("wirePropsWith does not support the type: [NotProducer]"), - "wirePropsWithProducer-11-toManyInjectAnnotations" -> List("Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActorProducer]"), - "wirePropsWithProducer-12-noPublicConstructor" -> List("Cannot find a public constructor for [SomeActorProducer]"), + "wirePropsWithProducer-11-toManyInjectAnnotations" -> List( + "Ambiguous constructors annotated with @javax.inject.Inject for type [SomeActorProducer]" + ), + "wirePropsWithProducer-12-noPublicConstructor" -> List( + "Cannot find a public constructor for [SomeActorProducer]" + ), "wirePropsWithProducer-13-missingImplicitDependency" -> List("could not find implicit value for parameter e: D") ), expectedWarnings = List() diff --git a/macrosPekkoTests/src/test/scala/com/softwaremill/macwire/pekkosupport/demo/Demo.scala b/macrosPekkoTests/src/test/scala/com/softwaremill/macwire/pekkosupport/demo/Demo.scala index 5e4dbf5..49db9f2 100644 --- a/macrosPekkoTests/src/test/scala/com/softwaremill/macwire/pekkosupport/demo/Demo.scala +++ b/macrosPekkoTests/src/test/scala/com/softwaremill/macwire/pekkosupport/demo/Demo.scala @@ -20,7 +20,8 @@ object Demo extends App { val bertaSinger = wireActor[SingerActor]("berta").taggedWith[Singer] val singers = wireSet[ActorRef @@ Singer] - val `4 voices polyphone` = system.actorOf(wireProps[PolyphoneActor].withRouter(RoundRobinPool(4))).taggedWith[Polyphone] + val `4 voices polyphone` = + system.actorOf(wireProps[PolyphoneActor].withRouter(RoundRobinPool(4))).taggedWith[Polyphone] val orchestra = wireAnonymousActor[OrchestraActor] @@ -33,45 +34,44 @@ object Demo extends App { system.terminate() } - trait Score case object Play case object PlaySoloPolyphone trait Polyphone class PolyphoneActor extends Actor { - override def receive: Receive = { - case Play => println(s"Polyphone ${self.path.name} is playing: uouiiiiiiiiiii") + override def receive: Receive = { case Play => + println(s"Polyphone ${self.path.name} is playing: uouiiiiiiiiiii") } } trait Violin class ViolinActor(score: Score) extends Actor { - override def receive: Receive = { - case Play => println("Violin is playing: uuuuuuu ...") + override def receive: Receive = { case Play => + println("Violin is playing: uuuuuuu ...") } } trait Guitar -class GuitarActor(score: Score) extends Actor { - override def receive: Receive = { - case Play => println("Guitar is playing: pa pa pppaaa ...") +class GuitarActor(score: Score) extends Actor { + override def receive: Receive = { case Play => + println("Guitar is playing: pa pa pppaaa ...") } } trait Singer class SingerActor(score: Score) extends Actor { - override def receive: Receive = { - case Play => println(s"${self.path.name} is singing: aaaaa uuuu eeee") + override def receive: Receive = { case Play => + println(s"${self.path.name} is singing: aaaaa uuuu eeee") } } trait Orchestra class OrchestraActor( - v: ActorRef @@ Violin, - g: ActorRef @@ Guitar, - polyphone: ActorRef @@ Polyphone, - choir: Set[ActorRef @@ Singer] + v: ActorRef @@ Violin, + g: ActorRef @@ Guitar, + polyphone: ActorRef @@ Polyphone, + choir: Set[ActorRef @@ Singer] ) extends Actor { val supportiveChoirScore = new Score {} @@ -87,6 +87,6 @@ class OrchestraActor( polyphone ! Play case PlaySoloPolyphone => polyphone ! Play - //...whatever + // ...whatever } } diff --git a/proxy/src/test/scala/com/softwaremill/macwire/aop/ProxyingInterceptorTest.scala b/proxy/src/test/scala/com/softwaremill/macwire/aop/ProxyingInterceptorTest.scala index a3d62e1..2b39dd4 100644 --- a/proxy/src/test/scala/com/softwaremill/macwire/aop/ProxyingInterceptorTest.scala +++ b/proxy/src/test/scala/com/softwaremill/macwire/aop/ProxyingInterceptorTest.scala @@ -28,13 +28,13 @@ class ProxyingInterceptorTest extends AnyFlatSpec with Matchers { val bResult = intercepted.methodB(10) // then - toIntercept.a should be (1) - toIntercept.b should be (11) + toIntercept.a should be(1) + toIntercept.b should be(11) - bResult should be (11) + bResult should be(11) - before should be (2) - after should be (2) + before should be(2) + after should be(2) } class SomeClass { diff --git a/proxy/src/test/scala/com/softwaremill/macwire/scopes/ThreadLocalScopeTest.scala b/proxy/src/test/scala/com/softwaremill/macwire/scopes/ThreadLocalScopeTest.scala index 60e8625..02f9ef8 100644 --- a/proxy/src/test/scala/com/softwaremill/macwire/scopes/ThreadLocalScopeTest.scala +++ b/proxy/src/test/scala/com/softwaremill/macwire/scopes/ThreadLocalScopeTest.scala @@ -27,7 +27,7 @@ but - special handling for wire, new ... needed; still wouldn't work in the general case - can you do macro inside a macro? -*/ + */ class ThreadLocalScopeTest extends AnyFlatSpec with Matchers { it should "store object values per-storage" in { // Given @@ -49,15 +49,15 @@ class ThreadLocalScopeTest extends AnyFlatSpec with Matchers { // Then scope.associate(storage1) - bean.data should be ("2") + bean.data should be("2") scope.disassociate() scope.associate(storage2) - bean.data should be ("3") + bean.data should be("3") scope.disassociate() scope.associate(storage3) - bean.data should be ("1") + bean.data should be("1") scope.disassociate() } @@ -75,7 +75,7 @@ class ThreadLocalScopeTest extends AnyFlatSpec with Matchers { // Then scope.associate(storage) - bean.data should be ("2") + bean.data should be("2") scope.disassociate() } @@ -98,7 +98,7 @@ class ThreadLocalScopeTest extends AnyFlatSpec with Matchers { // Then scope.associate(storage) - Beans.service1.fetchData should be ("2") + Beans.service1.fetchData should be("2") scope.disassociate() } } diff --git a/tests/src/test/scala-2/com/softwaremill/macwire/CompileTests.scala b/tests/src/test/scala-2/com/softwaremill/macwire/CompileTests.scala index 2e7bbd4..183b1b7 100644 --- a/tests/src/test/scala-2/com/softwaremill/macwire/CompileTests.scala +++ b/tests/src/test/scala-2/com/softwaremill/macwire/CompileTests.scala @@ -4,10 +4,17 @@ class CompileTests extends CompileTestsSupport { runTestsWith( expectedFailures = List( - "companionFactoryAmbiguous" -> List("No public primary constructor found for", "Test.PrivConstructor", - "and multiple matching apply methods in its companion object were found."), + "companionFactoryAmbiguous" -> List( + "No public primary constructor found for", + "Test.PrivConstructor", + "and multiple matching apply methods in its companion object were found." + ), "explicitDepsNotWiredWithImplicitVals" -> List(valueNotFound("A")), - "explicitDepsWiredWithImplicitValsFromMethodScope" -> List(ambiguousResMsg("A"), "dependency", "implicitDependencyA"), + "explicitDepsWiredWithImplicitValsFromMethodScope" -> List( + ambiguousResMsg("A"), + "dependency", + "implicitDependencyA" + ), "importAmbiguous" -> List(ambiguousResMsg("A"), "myA", "theA"), "nestedMethodsWired" -> List(ambiguousResMsg("A"), "outerA", "innerA"), "nestedWithManyMatchingParamsWired" -> List(ambiguousResMsg("A"), "a1", "a2", "a3"), @@ -16,15 +23,23 @@ class CompileTests extends CompileTestsSupport { "simpleValsDuplicateValue" -> List(ambiguousResMsg("B"), "theB1", "theB2"), "secondaryConstructorNotAnnotated" -> List(valueNotFound("String")), "phantomConstructor" -> List("Cannot find a public constructor nor a companion object for [Target]"), - "companionObjectHasNoMethods" -> List("Companion object for", "Target] has no apply methods constructing target type."), - "companionObjectHasFakeApplyMethods" -> List("Companion object for", "Target] has no apply methods constructing target type."), + "companionObjectHasNoMethods" -> List( + "Companion object for", + "Target] has no apply methods constructing target type." + ), + "companionObjectHasFakeApplyMethods" -> List( + "Companion object for", + "Target] has no apply methods constructing target type." + ), "toManyInjectAnnotations" -> List("Ambiguous constructors annotated with @javax.inject.Inject for type [Target]"), "nullaryMethodUsedAsCandidate" -> List("Found multiple values of type [A]: [List(Module.foo(), a)]"), "wireWithTwoParamsLists" -> List("found : A => (B => __wrapper$1", "required: ? => __wrapper$1"), "wireRecEmptyString" -> List(valueNotFound("String")) ), expectedWarnings = List( - "forwardReferenceInBlock" -> List("Found [a] for parameter [a], but a forward reference [forwardA] was also eligible") + "forwardReferenceInBlock" -> List( + "Found [a] for parameter [a], but a forward reference [forwardA] was also eligible" + ) ) ) } diff --git a/tests/src/test/scala-3/com/softwaremill/macwire/CompileTests.scala b/tests/src/test/scala-3/com/softwaremill/macwire/CompileTests.scala index a0c9b8e..aee4cfc 100644 --- a/tests/src/test/scala-3/com/softwaremill/macwire/CompileTests.scala +++ b/tests/src/test/scala-3/com/softwaremill/macwire/CompileTests.scala @@ -4,23 +4,38 @@ class CompileTests extends CompileTestsSupport { runTestsWith( expectedFailures = List( - "companionFactoryAmbiguous" -> List("No public primary constructor found for", "PrivConstructor", - "and multiple matching apply methods in its companion object were found."), + "companionFactoryAmbiguous" -> List( + "No public primary constructor found for", + "PrivConstructor", + "and multiple matching apply methods in its companion object were found." + ), "explicitDepsNotWiredWithImplicitVals" -> List(valueNotFound("A")), - "explicitDepsWiredWithImplicitValsFromMethodScope" -> List(ambiguousResMsg("A"), "dependency", "implicitDependencyA"), + "explicitDepsWiredWithImplicitValsFromMethodScope" -> List( + ambiguousResMsg("A"), + "dependency", + "implicitDependencyA" + ), "nestedMethodsWired" -> List(ambiguousResMsg("A"), "outerA", "innerA"), "nestedWithManyMatchingParamsWired" -> List(ambiguousResMsg("A"), "a1", "a2", "a3"), "multipleMethodParameters" -> List(ambiguousResMsg("A"), "a1", "a2"), "simpleValsMissingValue" -> List(valueNotFound("B")), "simpleValsDuplicateValue" -> List(ambiguousResMsg("B"), "theB1", "theB2"), "secondaryConstructorNotAnnotated" -> List(valueNotFound("String")), - //Scala 3 automatically generates a companion for any class + // Scala 3 automatically generates a companion for any class "phantomConstructor" -> List("Cannot find a public constructor", "[Target]"), - "companionObjectHasNoMethods" -> List("companion object", "has no apply methods constructing target type", "[Target]"), - "companionObjectHasFakeApplyMethods" -> List("companion object", "has no apply methods constructing target type", "[Target]"), + "companionObjectHasNoMethods" -> List( + "companion object", + "has no apply methods constructing target type", + "[Target]" + ), + "companionObjectHasFakeApplyMethods" -> List( + "companion object", + "has no apply methods constructing target type", + "[Target]" + ), "toManyInjectAnnotations" -> List("Ambiguous constructors annotated with @javax.inject.Inject for type [Target]"), "wireWithTwoParamsLists" -> List("Found: Main.A => Main.B => Main.Test.C", "Required: Any => Main.Test.C"), "wireRecEmptyString" -> List(valueNotFound("String")) - ), + ) ) } diff --git a/tests2/src/test/scala-2/com/softwaremill/macwire/two_modules_and_scope/SomeModule.scala b/tests2/src/test/scala-2/com/softwaremill/macwire/two_modules_and_scope/SomeModule.scala index 02c98cb..5405031 100644 --- a/tests2/src/test/scala-2/com/softwaremill/macwire/two_modules_and_scope/SomeModule.scala +++ b/tests2/src/test/scala-2/com/softwaremill/macwire/two_modules_and_scope/SomeModule.scala @@ -9,5 +9,3 @@ trait SomeModule { def x: Scope } - - diff --git a/util-tests/src/test/scala-2/com/softwaremill/macwire/CompileTests.scala b/util-tests/src/test/scala-2/com/softwaremill/macwire/CompileTests.scala index a71901c..2c74367 100644 --- a/util-tests/src/test/scala-2/com/softwaremill/macwire/CompileTests.scala +++ b/util-tests/src/test/scala-2/com/softwaremill/macwire/CompileTests.scala @@ -7,6 +7,7 @@ class CompileTests extends CompileTestsSupport { "methodWithTaggedParamsNotFound" -> List(valueNotFound("Berry @@ Blue")), "methodWithTaggedParamsAmbiguous" -> List(ambiguousResMsg("Berry @@ Blue"), "blueberryArg1", "blueberryArg2"), "moduleAmbiguousWithParent" -> List(ambiguousResMsg("A"), "module.a", "parentA"), - "taggedNoValueWithTag" -> List(valueNotFound("Berry @@ Blue"))) + "taggedNoValueWithTag" -> List(valueNotFound("Berry @@ Blue")) + ) ) } diff --git a/util-tests/src/test/scala-3/com/softwaremill/macwire/CompileTests.scala b/util-tests/src/test/scala-3/com/softwaremill/macwire/CompileTests.scala index bf873cd..27f6b98 100644 --- a/util-tests/src/test/scala-3/com/softwaremill/macwire/CompileTests.scala +++ b/util-tests/src/test/scala-3/com/softwaremill/macwire/CompileTests.scala @@ -1,11 +1,12 @@ package com.softwaremill.macwire class CompileTests extends CompileTestsSupport { - //FIXME we currently print only `@@` instead of full type name + // FIXME we currently print only `@@` instead of full type name runTestsWith( expectedFailures = List( "methodWithTaggedParamsNotFound" -> List(valueNotFound("@@")), "methodWithTaggedParamsAmbiguous" -> List(ambiguousResMsg("@@"), "blueberryArg1", "blueberryArg2"), - "taggedNoValueWithTag" -> List(valueNotFound("@@"))) + "taggedNoValueWithTag" -> List(valueNotFound("@@")) + ) ) } diff --git a/util-tests/src/test/scala/com/softwaremill/macwire/WiredTest.scala b/util-tests/src/test/scala/com/softwaremill/macwire/WiredTest.scala index 6a6dc14..4ad4b1d 100644 --- a/util-tests/src/test/scala/com/softwaremill/macwire/WiredTest.scala +++ b/util-tests/src/test/scala/com/softwaremill/macwire/WiredTest.scala @@ -7,7 +7,9 @@ import org.scalatest.flatspec.AnyFlatSpec class WiredTest extends AnyFlatSpec with Matchers { import WiredTest._ - def createInstanceFactoryMap(instances: AnyRef*): InstanceFactoryMap = Map(instances.map(i => i.getClass -> (() => i)): _*) + def createInstanceFactoryMap(instances: AnyRef*): InstanceFactoryMap = Map( + instances.map(i => i.getClass -> (() => i)): _* + ) val implsMap1 = createInstanceFactoryMap(new X, new Y, new Z) val implsMap2 = createInstanceFactoryMap(new Z, new M) @@ -48,7 +50,7 @@ class WiredTest extends AnyFlatSpec with Matchers { def testLookup(map: InstanceFactoryMap, cls: Class[_], expectedCount: Int): Unit = { val result = new Wired(map).lookup(cls) result should have size (expectedCount) - result.foreach(r => cls.isAssignableFrom(r.getClass) should be (true)) + result.foreach(r => cls.isAssignableFrom(r.getClass) should be(true)) } it should "expand the wired instance factories map with the given instances" in { @@ -59,11 +61,11 @@ class WiredTest extends AnyFlatSpec with Matchers { val wired = original.withInstances(new Y, new Z) // then - original.lookup(classOf[A]).size should be (0) - wired.lookup(classOf[A]).size should be (2) + original.lookup(classOf[A]).size should be(0) + wired.lookup(classOf[A]).size should be(2) - original.lookup(classOf[Z]).size should be (0) - wired.lookup(classOf[Z]).size should be (1) + original.lookup(classOf[Z]).size should be(0) + wired.lookup(classOf[Z]).size should be(1) } it should "expand the wired instance factories map with the given instance factory" in { @@ -74,10 +76,10 @@ class WiredTest extends AnyFlatSpec with Matchers { val wired = original.withInstanceFactory(() => new Y) // then - original.lookup(classOf[Y]).size should be (0) - wired.lookup(classOf[Y]).size should be (1) + original.lookup(classOf[Y]).size should be(0) + wired.lookup(classOf[Y]).size should be(1) - (wired.lookup(classOf[Y]).apply(0) eq wired.lookup(classOf[Y]).apply(0)) should be (false) + (wired.lookup(classOf[Y]).apply(0) eq wired.lookup(classOf[Y]).apply(0)) should be(false) } val x = new X @@ -91,33 +93,33 @@ class WiredTest extends AnyFlatSpec with Matchers { val result = wiredXYZM.wireClassInstance(classOf[NoDeps]) result should not be (null) - result.getClass should be (classOf[NoDeps]) + result.getClass should be(classOf[NoDeps]) } it should "create an instance of a class with one exact dependency" in { val result = wiredXYZM.wireClassInstance(classOf[OneExactDep]) - result.x should be (x) + result.x should be(x) } it should "create an instance of a class with one subtype dependency" in { val result = wiredXYZM.wireClassInstance(classOf[OneSubtypeDep]) - result.c should be (z) + result.c should be(z) } it should "create an instance of a class with multiple dependencies" in { val result = wiredXYZM.wireClassInstance(classOf[MultipleDeps]) - result.y should be (y) - result.c should be (z) + result.y should be(y) + result.c should be(z) } it should "create an instance of a class given by string" in { val result = wiredXYZM.wireClassInstanceByName(classOf[OneExactDep].getName) - result.isInstanceOf[OneExactDep] should be (true) - result.asInstanceOf[OneExactDep].x should be (x) + result.isInstanceOf[OneExactDep] should be(true) + result.asInstanceOf[OneExactDep].x should be(x) } it should "fail to create an instance of a class if dependencies are not found" in { From c855175c9cec5c289645de94d4ca4d188027974a Mon Sep 17 00:00:00 2001 From: scala-steward Date: Wed, 15 Jan 2025 15:36:29 +0000 Subject: [PATCH 3/3] Add 'Reformat with scalafmt 3.8.4' to .git-blame-ignore-revs --- .git-blame-ignore-revs | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .git-blame-ignore-revs diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000..37585ca --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# Scala Steward: Reformat with scalafmt 3.8.4 +f02d45a6f6abeed0724ab0224e05437fc58cbd56