From 4a8812bbeb11aa6376408f416ad6a9a28ebab4ee Mon Sep 17 00:00:00 2001 From: Adam Warski Date: Mon, 16 Sep 2024 12:22:57 +0200 Subject: [PATCH] Rename membersOf to autowireMembersOf (#350) --- README.md | 4 ++-- .../macwire/internals/autowire/AutowireProviders.scala | 2 +- .../src/main/scala-3/com/softwaremill/macwire/macwire.scala | 4 ++-- .../autowire/{membersOf.success => autowireMembersOf.success} | 2 +- ...OfDuplicate.failure => autowireMembersOfDuplicate.failure} | 2 +- .../com/softwaremill/macwire/AutowireCompileTests.scala | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) rename tests/src/test/resources/test-cases/autowire/{membersOf.success => autowireMembersOf.success} (81%) rename tests/src/test/resources/test-cases/autowire/{membersOfDuplicate.failure => autowireMembersOfDuplicate.failure} (77%) diff --git a/README.md b/README.md index 49387e06..427f5230 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ of the default construct/`apply` mechanism. These are described in detail below. * an instance to use * a function to create an instance * a class to instantiate to provide a dependency for the types it implements (provided as: `classOf[SomeType]`) -* a `membersOf(instance)` call, to use the members of the given instance as dependencies +* a `autowireMembersOf(instance)` call, to use the members of the given instance as dependencies `autowire` is context-free: its result does not depend on the environment, within which it is called (except for implicit parameters, which are looked up using the usual mechanism). It only depends on the type that is specified @@ -183,7 +183,7 @@ Without the `classOf[]`, MacWire wouldn't know how to create an instance impleme ## Using dependencies contained in objects -Finally, it's possible to use the members of a given instance as dependencies. Simply pass a `memberOf(someInstance)` +Finally, it's possible to use the members of a given instance as dependencies. Simply pass a `autowireMembersOf(someInstance)` as a parameter to `autowire`. ## Errors diff --git a/macros/src/main/scala-3/com/softwaremill/macwire/internals/autowire/AutowireProviders.scala b/macros/src/main/scala-3/com/softwaremill/macwire/internals/autowire/AutowireProviders.scala index 5d7e4284..35d0151f 100644 --- a/macros/src/main/scala-3/com/softwaremill/macwire/internals/autowire/AutowireProviders.scala +++ b/macros/src/main/scala-3/com/softwaremill/macwire/internals/autowire/AutowireProviders.scala @@ -55,7 +55,7 @@ class AutowireProviders[Q <: Quotes](using val q: Q)( else Vector.empty val membersOfProviders = - if term.show.startsWith("com.softwaremill.macwire.macwire$package.membersOf") then + if term.show.startsWith("com.softwaremill.macwire.macwire$package.autowireMembersOf") then providersFromMembersOf(term) else Vector.empty diff --git a/macros/src/main/scala-3/com/softwaremill/macwire/macwire.scala b/macros/src/main/scala-3/com/softwaremill/macwire/macwire.scala index 491abe0b..57de7a00 100644 --- a/macros/src/main/scala-3/com/softwaremill/macwire/macwire.scala +++ b/macros/src/main/scala-3/com/softwaremill/macwire/macwire.scala @@ -9,7 +9,7 @@ import com.softwaremill.macwire.internals.MacwireMacros * - an instance to use * - a function to create an instance * - a class to instantiate to provide a dependency for the types it implements (provided as: `classOf[SomeType]`) - * - a `membersOf(instance)` call, to use the members of the given instance as dependencies + * - a `autowireMembersOf(instance)` call, to use the members of the given instance as dependencies * * Any missing dependenciess will be created using the publicly available primary constructors or apply methods. * @@ -113,4 +113,4 @@ inline def wireRec[T]: T = ${ MacwireMacros.wireRecImpl[T] } /** Marker method to be used in [[autowire]], to specify that values defined in the given value should be used for * wiring. */ -def membersOf[T](t: T): T = ??? +def autowireMembersOf[T](t: T): T = ??? diff --git a/tests/src/test/resources/test-cases/autowire/membersOf.success b/tests/src/test/resources/test-cases/autowire/autowireMembersOf.success similarity index 81% rename from tests/src/test/resources/test-cases/autowire/membersOf.success rename to tests/src/test/resources/test-cases/autowire/autowireMembersOf.success index ebe5d2c5..ef535c2b 100644 --- a/tests/src/test/resources/test-cases/autowire/membersOf.success +++ b/tests/src/test/resources/test-cases/autowire/autowireMembersOf.success @@ -6,7 +6,7 @@ class Deps(val a: A, b: B): case class C(a: A, b: B) val d = new Deps(new A {}, new B {}) -val c = autowire[C](membersOf(d)) +val c = autowire[C](autowireMembersOf(d)) assert(c.a eq d.a) assert(c.b eq d.bb) diff --git a/tests/src/test/resources/test-cases/autowire/membersOfDuplicate.failure b/tests/src/test/resources/test-cases/autowire/autowireMembersOfDuplicate.failure similarity index 77% rename from tests/src/test/resources/test-cases/autowire/membersOfDuplicate.failure rename to tests/src/test/resources/test-cases/autowire/autowireMembersOfDuplicate.failure index ef8ad9b7..103464b8 100644 --- a/tests/src/test/resources/test-cases/autowire/membersOfDuplicate.failure +++ b/tests/src/test/resources/test-cases/autowire/autowireMembersOfDuplicate.failure @@ -6,4 +6,4 @@ class Deps(val a: A, b: B): case class C(a: A, b: B) val d = new Deps(new A, new B) -autowire[C](membersOf(d), new A) +autowire[C](autowireMembersOf(d), new A) diff --git a/tests/src/test/scala-3/com/softwaremill/macwire/AutowireCompileTests.scala b/tests/src/test/scala-3/com/softwaremill/macwire/AutowireCompileTests.scala index d76fef40..29b0fdc4 100644 --- a/tests/src/test/scala-3/com/softwaremill/macwire/AutowireCompileTests.scala +++ b/tests/src/test/scala-3/com/softwaremill/macwire/AutowireCompileTests.scala @@ -17,6 +17,6 @@ class AutowireCompileTests extends CompileTestsSupport: "cannot find a provided dependency, public constructor or public apply method for: A;", "wiring path: B -> A" ), - "membersOfDuplicate" -> List("duplicate type in dependencies list: A, for: new A()") + "autowireMembersOfDuplicate" -> List("duplicate type in dependencies list: A, for: new A()") ) )