{"id":15037515,"url":"https://github.com/softwaremill/macwire","last_synced_at":"2025-12-18T03:09:50.403Z","repository":{"id":7485968,"uuid":"8834633","full_name":"softwaremill/macwire","owner":"softwaremill","description":"Zero-cost, compile-time, type-safe dependency injection library.","archived":false,"fork":false,"pushed_at":"2025-12-13T00:33:49.000Z","size":1497,"stargazers_count":1311,"open_issues_count":56,"forks_count":79,"subscribers_count":54,"default_branch":"master","last_synced_at":"2025-12-13T06:29:21.208Z","etag":null,"topics":["dependency-injection","macwire","scala"],"latest_commit_sha":null,"homepage":"https://softwaremill.com/open-source/","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/softwaremill.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2013-03-17T13:20:04.000Z","updated_at":"2025-12-13T00:33:51.000Z","dependencies_parsed_at":"2023-12-26T01:28:20.283Z","dependency_job_id":"b9aaa862-e33b-46a5-a964-3f266fe32548","html_url":"https://github.com/softwaremill/macwire","commit_stats":{"total_commits":586,"total_committers":40,"mean_commits":14.65,"dds":0.5,"last_synced_commit":"3067318f45cc716c8de9c992e20e93553be2fae1"},"previous_names":["adamw/macwire"],"tags_count":56,"template":false,"template_full_name":null,"purl":"pkg:github/softwaremill/macwire","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softwaremill%2Fmacwire","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softwaremill%2Fmacwire/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softwaremill%2Fmacwire/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softwaremill%2Fmacwire/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/softwaremill","download_url":"https://codeload.github.com/softwaremill/macwire/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softwaremill%2Fmacwire/sbom","scorecard":{"id":836364,"data":{"date":"2025-08-11","repo":{"name":"github.com/softwaremill/macwire","commit":"d0ef11a27a2d6fd1f0cee103bb80f47abb35a5a2"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5.2,"checks":[{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Warn: no topLevel permission defined: .github/workflows/scala-steward.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":9,"reason":"Found 29/30 approved changesets -- score normalized to 9","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":10,"reason":"13 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/softwaremill/macwire/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/softwaremill/macwire/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:37: update your workflow using https://app.stepsecurity.io/secureworkflow/softwaremill/macwire/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:43: update your workflow using https://app.stepsecurity.io/secureworkflow/softwaremill/macwire/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/scala-steward.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/softwaremill/macwire/scala-steward.yml/master?enable=pin","Info:   0 out of   5 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.txt:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 29 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T19:09:19.385Z","repository_id":7485968,"created_at":"2025-08-23T19:09:19.385Z","updated_at":"2025-08-23T19:09:19.385Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27790151,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-18T02:00:09.725Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dependency-injection","macwire","scala"],"created_at":"2024-09-24T20:34:53.195Z","updated_at":"2025-12-18T03:09:50.396Z","avatar_url":"https://github.com/softwaremill.png","language":"Scala","readme":"![MacWire](https://github.com/softwaremill/macwire/raw/master/banner.png)\n\n[![Ideas, suggestions, problems, questions](https://img.shields.io/badge/Discourse-ask%20question-blue)](https://softwaremill.community/c/macwire)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.softwaremill.macwire/macros_2.13/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.softwaremill.macwire/macros_2.13)\n\nZero-cost, compile-time, type-safe dependency injection library.\n\nThe core of MacWire is a set of macros, that is code which runs at compile-time. The macros generate the `new` instance\ncreation code automatically, allowing you to avoid a ton of boilerplate code, while maintaining type-safety.\n\nThe core library has no dependencies, and incurs no run-time overhead. The main mechanism of defining dependencies of a\nclass are plain constructors or `apply` methods in companion objects. MacWire doesn't impact the code of your classes \nin any way, there are no annotations that you have to use or conventions to follow.\n\nThere's a couple of wiring variants that you can choose from:\n\n* `autowire` create an instance of the given type, using the provided dependencies. Any missing dependencies are created\n  using constructors/`apply` methods.\n* `wire` create an instance of the given type, using dependencies from the context, within which it is called. \n  Dependencies are looked up in the enclosing trait/class/object and parents (via inheritance).\n* `wireRec` is a variant of `wire`, which creates missing dependencies using constructors.\n* `wireSet` collect all instances of the given type from the context and return them as a `Set`.\n* `wireList` collect all instances of the given type from the context and return them as a `List`, preserving order.\n\nIn other words, `autowire` is context-free, while the `wire` family of macros is context-dependent.\n\nMacWire is available for Scala 2.12, 2.13 and 3 on the JVM, JS and Native platforms. Not all functionalities are \navailable for each Scala version.\n\nTo use, add the following dependency:\n\n```\n// sbt\n\"com.softwaremill.macwire\" %% \"macros\" % \"2.6.7\" % \"provided\"\n\n// scala-cli\n//\u003e using dep com.softwaremill.macwire::macros:2.6.7\n```\n\n# Table of Contents\n\n- [Table of Contents](#table-of-contents)\n- [autowire](#autowire)\n  - [Providing instantiated dependencies](#providing-instantiated-dependencies)\n  - [Using factories](#using-factories)\n  - [Specifying implementations to use](#specifying-implementations-to-use)\n  - [Using dependencies contained in objects](#using-dependencies-contained-in-objects)\n  - [Errors](#errors)\n  - [Limitiations of autowire](#limitiations-of-autowire)\n- [wire](#wire)\n\t- [How wiring works](#how-wiring-works)\n\t- [Factories](#factories)\n\t- [Factory methods](#factory-methods)\n\t- [`lazy val` vs. `val`](#lazy-val-vs-val)\n\t- [Recursive wiring](#recursive-wiring)\n\t- [Composing modules](#composing-modules)\n\t- [Scopes](#scopes)\n\t- [Accessing wired instances dynamically](#accessing-wired-instances-dynamically)\n  - [Limitations](#limitations)\n  - [Akka integration](#akka-integration)\n  - [Multi Wiring (wireSet and wireList)](#multi-wiring-wireset-and-wirelist)\n- [Autowire for cats-effect](#autowire-for-cats-effect)  \n- [Interceptors](#interceptors)\n- [Qualifiers](#qualifiers)\n- [Development](#development)\t\n\t- [Debugging](#debugging)\n\t- [Future development - vote!](#future-development---vote)\n- [Platform and version-specifics](#platform-and-version-specifics)  \n\t- [Scala.js](#scalajs)\n  - [Scala3 support](#scala3-support)\n- [Other](#other)\n  - [Commerical support](#commercial-support)\n  - [Copyright](#copyright)\n\n# autowire\n\n![Scala 3](https://img.shields.io/badge/Scala%203-8A2BE2)\n![direct-style](https://img.shields.io/badge/direct--style-228B22)\n\nAutowire generates the code needed to instantiate the given type. To create the instance, the public primary \nconstructor is used, or if one is absent - the `apply` method from the companion object. Any dependencies are\ncreated recursively. For example, given the following classes:\n\n```scala\nclass DatabaseAccess()\nclass SecurityFilter()\nclass UserFinder(databaseAccess: DatabaseAccess, securityFilter: SecurityFilter)\nclass UserStatusReader(userFinder: UserFinder)\n```\n\ninvoking `autowire` as below:\n\n```scala\nimport com.softwaremill.macwire.*\nval userStatusReader = autowire[UserStatusReader]()\n```\n\ngenerates following code:\n\n```scala\nval userStatusReader =\n  val wiredDatabaseAccess   = new DatabaseAccess()\n  val wiredSecurityFilter   = new SecurityFilter()\n  val wiredUserFinder       = new UserFinder(wiredDatabaseAccess, wiredSecurityFilter)\n  val wiredUserStatusReader = new UserStatusReader(wiredUserFinder)\n  wiredUserStatusReader\n```\n\n`autowire` accepts an arbitrary number of parameters, which specify how to lookup or create dependencies, instead\nof the default construct/`apply` mechanism. These are described in detail below. Each such parameter might be:\n\n* an instance to use\n* a function to create an instance\n* a class to instantiate to provide a dependency for the types it implements (provided as: `classOf[SomeType]`)\n* a `autowireMembersOf(instance)` call, to use the members of the given instance as dependencies\n\n`autowire` is context-free: its result does not depend on the environment, within which it is called (except for\nimplicit parameters, which are looked up using the usual mechanism). It only depends on the type that is specified\nfor wiring, and any parameters that are passed.\n\n## Providing instantiated dependencies\n\nIn some cases it's necessary to instantiate a dependency by hand, e.g. to initialise it with some configuration,\nor to manage its lifecycle. In such cases, dependencies can be provided as parameters to the `autowire` invocation.\nThey will be used whenever a value of the given type is needed.\n\nAs an example, consider a `DataSource`, which needs to be configured with a JDBC connection string, and has a \nmanaged life-cycle:\n\n```scala\nimport java.io.Closeable\n\nclass DataSource(jdbcConn: String) extends Closeable { def close() = () }\nclass DatabaseAccess(ds: DataSource)\nclass SecurityFilter()\nclass UserFinder(databaseAccess: DatabaseAccess, securityFilter: SecurityFilter)\nclass UserStatusReader(userFinder: UserFinder)\n```\n\nWe can provide a `DataSource` instance to be used by `autowire`:\n\n```scala\nimport com.softwaremill.macwire.*\nimport scala.util.Using\n\nUsing.resource(DataSource(\"jdbc:h2:~/test\")): ds =\u003e\n  autowire[UserStatusReader](ds)\n```\n\n## Using factories\n\nIn addition to instances, which should be used by `autowire`, it's also possible to provide factory methods. They will\nbe used to create instances of types which is the result of the provided function, using the dependencies which are the\nfunction's parameters. Any dependencies are recursively created. \n\nFor example, we can provide a custom way to create a `UserFinder`:\n\n```scala\nclass DatabaseAccess()\nclass SecurityFilter()\nclass UserFinder(databaseAccess: DatabaseAccess, securityFilter: SecurityFilter, \n  adminOnly: Boolean)\nclass UserStatusReader(userFinder: UserFinder)\n\nautowire[UserStatusReader](UserFinder(_, _, adminOnly = true))\n```\n\n## Specifying implementations to use\n\nYou can specify which classes to use to create instances. This is useful when the dependencies are expressed for \nexample using `trait`s, not the concrete types. Such a dependency can be expressed by providing a `classOf[]`\nparameter to `autowire`:\n\n```scala\ntrait DatabaseAccess\nclass DatabaseAccessImpl() extends DatabaseAccess\n\nclass SecurityFilter()\nclass UserFinder(databaseAccess: DatabaseAccess, securityFilter: SecurityFilter)\nclass UserStatusReader(userFinder: UserFinder)\n\nautowire[UserStatusReader](classOf[DatabaseAccessImpl])\n```\n\nWithout the `classOf[]`, MacWire wouldn't know how to create an instance implementing `DatabaseAccess`.\n\n## Using dependencies contained in objects\n\nFinally, it's possible to use the members of a given instance as dependencies. Simply pass a `autowireMembersOf(someInstance)` \nas a parameter to `autowire`.\n\n## Errors\n\n`autowire` reports an error when:\n\n* a dependency can't be created (e.g. there are no public constructors / `apply` methods)\n* there are circular dependencies\n* the provided dependencies contain a duplicate\n* a provided dependency is not used\n* a primitive or `String` type is used as a dependency (instead, use e.g. an opaque type)\n\nEach error contains the wiring path. For example, below there's no public constructor for `DatabaseAccess`, which\nresults in a compile-time error:\n\n```scala\nclass DatabaseAccess private ()\nclass SecurityFilter()\nclass UserFinder(databaseAccess: DatabaseAccess, securityFilter: SecurityFilter)\nclass UserStatusReader(userFinder: UserFinder)\n\nautowire[UserStatusReader]()\n\n// compile-time error:\n// cannot find a provided dependency, constructor or apply method for: DatabaseAccess;\n// wiring path: UserStatusReader -\u003e UserFinder -\u003e DatabaseAccess\n```\n\n## Limitiations of autowire\n\n`autowire` doesn't handle propagating generic type parameters, when creating missing dependencies using constructors or\n`apply` methods. E.g. if you have a `class B[X](a: A[X])`, and a `B[Int]` needs to be created, the specific value for \nthe type parameter `X` won't be propagated when resolving the dependencies.\n\nAs a work-around, you need to explicitly provide the generic dependencies with concrete type parameters. A generic \ndependency might appear multiple times, with different type parameters. To wire the classes from the example, you'd \nneed: `autowire[...](B[Int](_), someInstance: A[Int])` or similar.\n\n# wire\n\n![Scala 2](https://img.shields.io/badge/Scala%202-8A2BE2)\n![Scala 3](https://img.shields.io/badge/Scala%203-8A2BE2)\n![direct-style](https://img.shields.io/badge/direct--style-228B22)\n\nMacWire generates `new` instance creation code of given classes, using values in the enclosing type for constructor\nparameters, with the help of Scala Macros.\n\nFor a general introduction to DI in Scala, take a look at the [Guide to DI in Scala](http://di-in-scala.github.io/),\nwhich also features MacWire.\n\nMacWire helps to implement the Dependency Injection (DI) pattern, by removing the need to write the\nclass-wiring code by hand. Instead, it is enough to declare which classes should be wired, and how the instances\nshould be accessed (see Scopes).\n\nClasses to be wired should be organized in \"modules\", which can be Scala `trait`s, `class`es or `object`s.\nMultiple modules can be combined using inheritance or composition; values from the inherited/nested modules are also\nused for wiring.\n\nMacWire can be in many cases a replacement for DI containers, offering greater control on when and how classes are\ninstantiated, typesafety and using only language (Scala) mechanisms.\n\nExample usage:\n\n```scala\nclass DatabaseAccess()\nclass SecurityFilter()\nclass UserFinder(databaseAccess: DatabaseAccess, securityFilter: SecurityFilter)\nclass UserStatusReader(userFinder: UserFinder)\n\ntrait UserModule {\n  import com.softwaremill.macwire._\n\n  lazy val theDatabaseAccess   = wire[DatabaseAccess]\n  lazy val theSecurityFilter   = wire[SecurityFilter]\n  lazy val theUserFinder       = wire[UserFinder]\n  lazy val theUserStatusReader = wire[UserStatusReader]\n}\n```\n\nwill generate:\n\n```scala\ntrait UserModule {\n  lazy val theDatabaseAccess   = new DatabaseAccess()\n  lazy val theSecurityFilter   = new SecurityFilter()\n  lazy val theUserFinder       = new UserFinder(theDatabaseAccess, theSecurityFilter)\n  lazy val theUserStatusReader = new UserStatusReader(theUserFinder)\n}\n```\n\nFor testing, just extend the base module and override any dependencies with mocks/stubs etc, e.g.:\n\n```scala\ntrait UserModuleForTests extends UserModule {\n  override lazy val theDatabaseAccess = mockDatabaseAccess\n  override lazy val theSecurityFilter = mockSecurityFilter\n}\n```\n\nThe core library has no dependencies.\n\nFor more motivation behind the project see also these blogs:\n\n* [Dependency injection with Scala macros: auto-wiring](http://www.warski.org/blog/2013/03/dependency-injection-with-scala-macros-auto-wiring/)\n* [MacWire 0.1: Framework-less Dependency Injection with Scala Macros](http://www.warski.org/blog/2013/04/macwire-0-1-framework-less-dependency-injection-with-scala-macros/)\n* [MacWire 0.2: Scopes are simple!](http://www.warski.org/blog/2013/04/macwire-0-2-scopes-are-simple/)\n* [Implementing factories in Scala \u0026 MacWire 0.3](http://www.warski.org/blog/2013/06/implementing-factories-in-scala-macwire-0-3/)\n* [Dependency Injection in Play! with MacWire](http://www.warski.org/blog/2013/08/dependency-injection-in-play-with-macwire/)\n* [MacWire 0.5: Interceptors](http://www.warski.org/blog/2013/10/macwire-0-5-interceptors/)\n* [Using Scala traits as modules, or the \"Thin Cake\" Pattern](http://www.warski.org/blog/2014/02/using-scala-traits-as-modules-or-the-thin-cake-pattern/)\n\n## How wiring works\n\nFor each constructor parameter of the given class, MacWire tries to find a value [conforming](http://www.scala-lang.org/files/archive/spec/2.11/03-types.html#conformance) to the parameter's\ntype in the enclosing method and trait/class/object:\n\n* first it tries to find a unique value declared as a value in the current block, argument of enclosing methods\nand anonymous functions.\n* then it tries to find a unique value declared or imported in the enclosing type\n* then it tries to find a unique value in parent types (traits/classes)\n* if the parameter is marked as implicit, it is ignored by MacWire and handled by the normal implicit resolution mechanism\n\nHere value means either a `val` or a no-parameter `def`, as long as the return type matches.\n\nA compile-time error occurs if:\n\n* there are multiple values of a given type declared in the enclosing block/method/function's arguments list, enclosing type or its parents.\n* parameter is marked as implicit and implicit lookup fails to find a value\n* there is no value of a given type\n\nThe generated code is then once again type-checked by the Scala compiler.\n\n## Factories\n\nA factory is simply a method. The constructor of the wired class can contain parameters both from\nthe factory (method) parameters, and from the enclosing/super type(s).\n\nFor example:\n\n```scala\nclass DatabaseAccess()\nclass TaxDeductionLibrary(databaseAccess: DatabaseAccess)\nclass TaxCalculator(taxBase: Double, taxDeductionLibrary: TaxDeductionLibrary)\n\ntrait TaxModule {\n  import com.softwaremill.macwire._\n\n  lazy val theDatabaseAccess      = wire[DatabaseAccess]\n  lazy val theTaxDeductionLibrary = wire[TaxDeductionLibrary]\n  def taxCalculator(taxBase: Double) = wire[TaxCalculator]\n  // or: lazy val taxCalculator = (taxBase: Double) =\u003e wire[TaxCalculator]\n}\n```\n\nwill generate:\n\n```scala\ntrait TaxModule {\n  lazy val theDatabaseAccess      = new DatabaseAccess()\n  lazy val theTaxDeductionLibrary = new TaxDeductionLibrary(theDatabaseAccess)\n  def taxCalculator(taxBase: Double) =\n    new TaxCalculator(taxBase, theTaxDeductionLibrary)\n}\n```\n\n## Factory methods\n\nYou can also wire an object using a factory method, instead of a constructor. For that, use `wireWith` instead of\n`wire`. For example:\n\n```scala\nclass A()\n\nclass C(a: A, specialValue: Int)\nobject C {\n  def create(a: A) = new C(a, 42)\n}\n\ntrait MyModule {\n  lazy val a = wire[A]\n  lazy val c = wireWith(C.create _)\n}\n```\n\n## `lazy val` vs. `val`\n\nIt is safer to use `lazy val`s, as when using `val`, if a value is forward-referenced, it's value during initialization\nwill be `null`. With `lazy val` the correct order of initialization is resolved by Scala.\n\n## Recursive wiring\n\nWhen using `wire` and a value for a parameter can't be found, an error is reported. `wireRec` takes a different \napproach - it tries to recursively create an instance, using normal wiring rules. This allows to explicitly wire\nonly those objects, which are referenced from the code, skipping helper or internal ones.\n\nThe previous example becomes:\n\n```scala\nclass DatabaseAccess()\nclass SecurityFilter()\nclass UserFinder(databaseAccess: DatabaseAccess, securityFilter: SecurityFilter)\nclass UserStatusReader(userFinder: UserFinder)\n\ntrait UserModule {\n  import com.softwaremill.macwire._\n\n  lazy val theUserStatusReader = wireRec[UserStatusReader]\n}\n```\n\nand will generate:\n\n```scala\ntrait UserModule {\n  lazy val theUserStatusReader = new UserStatusReader(\n\t\tnew UserFinder(new DatabaseAccess(), new SecurityFilter()))\n}\n```\n\nThis feature is inspired by @yakivy's work on [jam](https://github.com/yakivy/jam).\n\n## Composing modules\n\nModules (traits or classes containing parts of the object graph) can be combined using inheritance or composition.\nThe inheritance case is straightforward, as `wire` simply looks for values in parent traits/classes. With composition,\nyou need to tell MacWire that it should look inside the nested modules.\n\nTo do that, you can use imports:\n\n```scala\nclass FacebookAccess(userFind: UserFinder)\n\nclass UserModule {\n  lazy val userFinder = ... // as before\n}\n\nclass SocialModule(userModule: UserModule) {\n  import userModule._\n\n  lazy val facebookAccess = wire[FacebookAccess]\n}\n```\n\n### Avoiding imports\n\nDependency:\n\n```scala\n\"com.softwaremill.macwire\" %% \"util\" % \"2.6.7\"\n```\n\nIf you are using that pattern a lot, you can annotate your modules using `@Module`, and they will be used when\nsearching for values automatically:\n\n```scala\nclass FacebookAccess(userFind: UserFinder)\n\n@Module\nclass UserModule { ... } // as before\n\nclass SocialModule(userModule: UserModule) {\n  lazy val facebookAccess = wire[FacebookAccess]\n}\n```\n\n## Scopes\n\nDependency:\n\n```\n\"com.softwaremill.macwire\" %% \"proxy\" % \"2.6.7\"\n```\n\nThere are two \"built-in\" scopes, depending on how the dependency is defined:\n* singleton: `lazy val` / `val`\n* dependent - separate instance for each dependency usage: `def`\n\nMacWire also supports user-defined scopes, which can be used to implement request or session scopes in web applications.\nThe `proxy` subproject defines a `Scope` trait, which has two methods:\n\n* `apply`, to create a scoped value\n* `get`, to get or create the current value from the scope\n\nTo define a dependency as scoped, we need a scope instance, e.g.:\n\n```scala\ntrait WebModule {\n   lazy val loggedInUser = session(new LoggedInUser)\n\n   def session: Scope\n}\n```\n\nWith abstract scopes as above, it is possible to use no-op scopes for testing (`NoOpScope`).\n\nThere's an implementation of `Scope` targeted at classical synchronous frameworks, `ThreadLocalScope`. The apply method\nof this scope creates a proxy (using [javassist](http://www.csg.is.titech.ac.jp/~chiba/javassist/)); the get method\nstores the value in a thread local. The proxy should be defined as a `val` or `lazy val`.\n\nIn a web application, the scopes have to be associated and disassociated with storages.\nThis can be done for example in a servlet filter.\nTo implement a:\n\n* request scope, we need a new empty storage for every request. The `associateWithEmptyStorage` is useful here\n* session scope, the storage (a `Map`) should be stored in the `HttpSession`. The `associate(Map)` method is useful here\n\nFor example usage see the\n[MacWire+Scalatra example](https://github.com/adamw/macwire/tree/master/examples/scalatra/src/main/scala/com/softwaremill/macwire/examples/scalatra)\nsources.\n\nYou can run the example with `sbt examples-scalatra/run` and going to [http://localhost:8080](http://localhost:8080).\n\nNote that the `proxy` subproject does not depend on MacWire core, and can be used stand-alone with manual wiring or any other\nframeworks.\n\n## Accessing wired instances dynamically\n\nDependency:\n\n```scala\n\"com.softwaremill.macwire\" %% \"util\" % \"2.6.7\"\n```\n\nTo integrate with some frameworks (e.g. [Play 2](http://www.playframework.com/)) or to create instances of classes\nwhich names are only known at run-time (e.g. plugins) it is necessary to access the wired instances dynamically.\nMacWire contains a utility class in the `util` subproject, `Wired`, to support such functionality.\n\nAn instance of `Wired` can be obtained using the `wiredInModule` macro, given an instance of a module containing the\nwired object graph. Any `vals`, `lazy val`s and parameter-less `def`s (factories) from the module which are references\nwill be available in the `Wired` instance.\n\nThe object graph in the module can be hand-wired, wired using `wire`, or a result of any computation.\n\n`Wired` has two basic functionalities: looking up an instance by its class (or trait it implements), and instantiating\nnew objects using the available dependencies. You can also extend `Wired` with new instances/instance factories.\n\nFor example:\n\n```scala\n// 1. Defining the object graph and the module\ntrait DatabaseConnector\nclass MysqlDatabaseConnector extends DatabaseConnector\n\nclass MyApp {\n  def securityFilter = new SecurityFilter()\n  val databaseConnector = new MysqlDatabaseConnector()\n}\n\n// 2. Creating a Wired instance\nimport com.softwaremill.macwire._\nval wired = wiredInModule(new MyApp)\n\n// 3. Dynamic lookup of instances\nwired.lookup(classOf[SecurityFilter])\n\n// Returns the mysql database connector, even though its type is MysqlDatabaseConnector, \n// which is assignable to DatabaseConnector.\nwired.lookup(classOf[DatabaseConnector])\n\n// 4. Instantiation using the available dependencies\n{\n  package com.softwaremill\n  class AuthenticationPlugin(databaseConnector: DatabaseConnector)\n}\n\n// Creates a new instance of the given class using the dependencies available in MyApp\nwired.wireClassInstanceByName(\"com.softwaremill.AuthenticationPlugin\")\n```\n\n## Limitations\n\nWhen:\n\n* referencing wired values within the trait/class/object\n* using multiple modules in the same compilation unit\n* using multiple modules with scopes\n\ndue to limitations of the current macros implementation in Scala (for more details see\n[this discussion](https://groups.google.com/forum/?fromgroups=#!topic/scala-user/k_2KCvO5g04))\nto avoid compilation errors it is recommended to add type ascriptions to the dependencies. This is a way of helping\nthe type-checker that is invoked by the macro to figure out the types of the values which\ncan be wired.\n\nFor example:\n\n```scala\nclass A()\nclass B(a: A)\n\n// note the explicit type. Without it wiring would fail with recursive type compile errors\nlazy val theA: A = wire[A]\n// reference to theA; if for some reason we need explicitly write the constructor call\nlazy val theB = new B(theA)\n```\n\nThis is an inconvenience, but hopefully will get resolved once post-typer macros are introduced to the language.\n\nAlso, wiring will probably not work properly for traits and classes defined inside the containing trait/class, or in\nsuper traits/classes.\n\nNote that the type ascription may be a subtype of the wired type. This can be useful if you want to expose e.g. a trait\nthat the wired class extends, instead of the full implementation.\n\n## Akka integration\n\nDependency:\n\n```scala\n\"com.softwaremill.macwire\" %% \"macrosakka\" % \"2.6.7\" % \"provided\"\n```\n\nMacwire provides wiring suport for [akka](http://akka.io) through the `macrosAkka` module.\n[Here](https://github.com/adamw/macwire/blob/master/macrosAkkaTests/src/test/scala/com/softwaremill/macwire/akkasupport/demo/Demo.scala)\nyou can find example code. The module adds three macros `wireAnonymousActor[A]`, `wireActor[A]` and `wireProps[A]`\n which help create instances of `akka.actor.ActorRef` and `akka.actor.Props`.\n\nThese macros require an `ActoRefFactory` (`ActorSystem` or `Actor.context`) to be in scope as a dependency.\nIf actor's primary constructor has dependencies - they are required to be in scope as well.\n\nExample usage:\n\n```scala\nimport akka.actor.{Actor, ActorRef, ActorSystem}\n\nclass DatabaseAccess()\nclass SecurityFilter()\nclass UserFinderActor(databaseAccess: DatabaseAccess, securityFilter: SecurityFilter) extends Actor {\n  override def receive: Receive = {\n    case m =\u003e // ...\n  }\n}\n\nimport com.softwaremill.macwire._\nimport com.softwaremill.macwire.akkasupport._\n\nval theDatabaseAccess = wire[DatabaseAccess] //1st dependency for UserFinderActor\n                                             //it compiles to: val theDatabaseAccess = new DatabaseAccess\n\nval theSecurityFilter = wire[SecurityFilter] //2nd dependency for UserFinderActor\n                                             //it compiles to: val theSecurityFilter = new SecurityFilter\n\nval system = ActorSystem(\"actor-system\") //there must be instance of ActoRefFactory in scope\n\nval theUserFinder = wireActor[UserFinderActor](\"userFinder\")\n//this compiles to:\n//lazy val theUserFinder = system.actorOf(Props(classOf[UserFinderActor], theDatabaseAccess, theSecurityFilter), \"userFinder\")\n```\n\nIn order to make it working all dependencies created `Actor`'s (`UserFinderActor`'s) primary constructor and\ninstance of the `akka.actor.ActorRefFactory` must be in scope. In above example this is all true. Dependencies\nof the `UserFinderActor` are `DatabaseAccess` and `SecurityFilter` and they are in scope.\nThe `ActorRefFactory` is in scope as well because `ActorSystem` which is subtype of it is there.\n\nCreating actor within another actor is even simpler than in first example because we don't need to have `ActorSystem` in scope.\nThe `ActorRefFactory` is here because `Actor.context` is subtype of it. Let's see this in action:\n\n```scala\nclass UserStatusReaderActor(theDatabaseAccess: DatabaseAccess) extends Actor {\n  val theSecurityFilter = wire[SecurityFilter]\n\n  val userFinder = wireActor[UserFinderActor](\"userFinder\")\n  //this compiles to:\n  //val userFinder = context.actorOf(Props(classOf[UserFinderActor], theDatabaseAccess, theSecurityFilter), \"userFinder\")\n\n  override def receive = ...\n}\n```\n\nThe difference is that previously macro expanded into `system.actorOf(...)`\nand when inside another actor it expanded into `context.actorOf(...)`.\n\n\nIt's possible to create anonymous actors. `wireAnonymousActor` is for it:\n\n```scala\nval userFinder = wireAnonymousActor[UserFinderActor]\n//this compiles to:\n//val userFinder = context.actorOf(Props(classOf[UserFinderActor], theDatabaseAccess, theSecurityFilter))\n```\n\nHow about creating `akka.actor.Props`? It's there and can be achieved by calling `wireProps[A]`.\nWiring only `Props` can be handy when it's required to setup the `Props` before passing them to the `actorOf(...)` method.\n\nLet's say we want to create some actor with router. It can be done as below:\n```scala\nval userFinderProps = wireProps[UserFinderActor] //create Props\n  //This compiles to: Props(classOf[UserFinderActor], theDatabaseAccess, theSecurityFilter)\n  .withRouter(RoundRobinPool(4)) //change it according requirements\nval userFinderActor = system.actorOf(userFinderProps, \"userFinder\")  //create the actor\n```\n\nHow about creating actors which depends on `ActorRef`s? The simplest way is to\npass them as arguments to the constructor. But how to distinguish two `actorRef`s representing two different actors?\nThey have the same type though.\n\n```scala\nclass DatabaseAccessActor extends Actor { ... }\nclass SecurityFilterActor extends Actor { ... }\nval db: ActorRef = wireActor[DatabaseAccessActor](\"db\")\nval filter: ActorRef = wireActor[SecurityFilterActor](\"filter\")\nclass UserFinderActor(databaseAccess: ActorRef, securityFilter: ActorRef) extends Actor {...}\n//val userFinder = wireActor[UserFinderActor] wont work here\n```\n\nWe can't just call `wireActor[UserFinderActor]` because it's not obvious which instance of ActorRef\nis for `databaseAccess` and which are for `securityFilter`. They are both of the same type - `ActorRef`.\n\nThe solution for it is to use earlier described [qualifiers](#qualifiers).\nIn above example solution for wiring may look like this:\n\n```scala\nsealed trait DatabaseAccess //marker type\nclass DatabaseAccessActor extends Actor { ... }\nsealed trait SecurityFilter //marker type\nclass SecurityFilterActor extends Actor { ... }\n\nval db: ActorRef @@ DatabaseAccess = wireActor[DatabaseAccessActor](\"db\").taggedWith[DatabaseAccess]\nval filter: ActorRef @@ SecurityFilter = wireActor[SecurityFilterActor](\"filter\").taggedWith[SecurityFilter]\n\nclass UserFinderActor(databaseAccess: ActorRef @@ DatabaseAccess, securityFilter: ActorRef @@ SecurityFilter) extends Actor {...}\n\nval userFinder = wireActor[UserFinderActor]\n```\n\nIt is also possible to wire an actor using a factory function.\nFor that, the module provides three additional macros `wireAnonymousActorWith`, `wireActorWith` and `wirePropsWith`.\nTheir usage is similar to `wireWith` (see [Factory methods](#factory-methods)).\nFor example:\n\n```scala\nclass UserFinderActor(databaseAccess: DatabaseAccess, securityFilter: SecurityFilter) extends Actor { ... }\n\nobject UserFinderActor {\n  def get(databaseAccess: DatabaseAccess) = new UserFinderActor(databaseAccess, new SimpleSecurityFilter())\n}\n\nval theUserFinder = wireActorWith(UserFinderActor.get _)(\"userFinder\")\n```\n\n## Multi Wiring (wireSet and wireList)\n\nUsing `wireSet` you can obtain a set of multiple instances of the same type. This is done without constructing the set explicitly. All instances of the same type which are found by MacWire are used to construct the set.\n\nUsing `wireList` you can obtain a list of multiple instances of the same type, preserving the order of definition. This works similarly to `wireSet`, but returns a `List` instead of a `Set`, maintaining the order in which the instances are discovered during macro expansion. This method is available only in Scala 3.\n\nConsider the below example. Let's suppose that you want to create a `RockBand` object with musicians:\n\n```scala\ntrait Musician\nclass RockBand(musicians: Set[Musician])\nclass Orchestra(musicians: List[Musician])\n\ntrait RockBandModule {\n  lazy val singer    = new Musician {}\n  lazy val guitarist = new Musician {}\n  lazy val drummer   = new Musician {}\n  lazy val bassist   = new Musician {}\n\n  lazy val musiciansSet = wireSet[Musician]  // all above musicians will be wired together\n                                             // musiciansSet has type Set[Musician] (unordered)\n\n  lazy val musiciansList = wireList[Musician] // all above musicians will be wired together\n                                              // musiciansList has type List[Musician] (preserves order)\n\n  lazy val rockBand  = wire[RockBand]\n  lazy val orchestra = wire[Orchestra]\n}\n```\n\nBoth `wireSet` and `wireList` look for instances in the same places:\n- enclosing members (lazy vals, vals, defs without parameters)\n- enclosing imports\n- parent classes and traits\n\nThe key difference is that `wireSet` returns an unordered `Set[T]` while `wireList` returns an ordered `List[T]` that preserves the order of definition discovery.\n\n# Autowire for cats-effect\n\n![Scala 2](https://img.shields.io/badge/Scala%202-8A2BE2)\n![cats-effect](https://img.shields.io/badge/cats--effect-228B22)\n\n**Warning**: `autowire` is an experimental feature, if you have any feedback regarding its usage, let us know! Future releases might break source/binary compatibility. It is available for Scala 2 only for now.\n\nDependency: `\"com.softwaremill.macwire\" %% \"macrosautocats\" % \"2.6.7\"`\n\nIn case you need to build an instance from some particular instances and factory methods you can leverage `autowire`. This feature is intended to integrate with effect-management libraries (currently we support [cats-effect](https://github.com/typelevel/cats-effect)).\n\n`autowire` takes as an argument a list of arguments which may contain:\n\n* values (e.g. `new A()`)\n* factory methods (e.g. `C.create _`)\n* factory methods that return `cats.effect.Resource` or `cats.effect.IO` (e.g. `C.createIO _`)\n* `cats.effect.Resource` (e.g. `cats.effect.Resource[IO].pure(new A())`)\n* `cats.effect.IO` (e.g. `cats.effect.IO.pure(new A())`)\n\nUsing the dependencies from the given arguments it creates an instance of the given type. Any missing instances are created using their primary constructor, provided that the dependencies are met. If this is not possible, a compile-time error is reported. In other words, a `wireRec` is performed, bypassing the instances search phase. \n\nThe result of the wiring is always wrapped in `cats.effect.Resource`. For example:\n\n```scala\nimport cats.effect._\n\nclass DatabaseAccess()\n\nclass SecurityFilter private (databaseAccess: DatabaseAccess)\nobject SecurityFilter {\n  def apply(databaseAccess: DatabaseAccess): SecurityFilter = new SecurityFilter(databaseAccess)\n}\n\nclass UserFinder(databaseAccess: DatabaseAccess, securityFilter: SecurityFilter)\nclass UserStatusReader(databaseAccess: DatabaseAccess, userFinder: UserFinder)\n\nobject UserModule {\n  import com.softwaremill.macwire.autocats._\n\n  val theDatabaseAccess: Resource[IO, DatabaseAccess] = Resource.pure(new DatabaseAccess())\n\n  val theUserStatusReader: Resource[IO, UserStatusReader] = autowire[UserStatusReader](theDatabaseAccess)\n}\n```\n\nwill generate:\n\n```scala\n[...]\nobject UserModule {\n  import com.softwaremill.macwire.autocats._\n\n  val theDatabaseAccess: Resource[IO, DatabaseAccess] = Resource.pure(new DatabaseAccess())\n\n  val theUserStatusReader: Resource[IO, UserStatusReader] = UserModule.this.theDatabaseAccess.flatMap(\n    da =\u003e Resource.pure[IO, UserStatusReader](new UserStatusReader(da, new UserFinder(da, SecurityFilter.apply(da))))\n  )\n}\n```\n\n# Interceptors\n\nDependency:\n\n```\n\"com.softwaremill.macwire\" %% \"proxy\" % \"2.6.7\"\n```\n\nMacWire contains an implementation of interceptors, which can be applied to class instances in the modules.\nSimilarly to scopes, the `proxy` subproject defines an `Interceptor` trait, which has only one method: `apply`.\nWhen applied to an instance, it should return an instance of the same class, but with the interceptor applied.\n\nThere are two implementations of the `Interceptor` trait provided:\n\n* `NoOpInterceptor`: returns the given instance without changes\n* `ProxyingInterceptor`: proxies the instance, and returns the proxy. A provided function is called\nwith information on the invocation\n\nInterceptors can be abstract in modules. E.g.:\n\n```scala\ntrait BusinessLogicModule {\n   lazy val moneyTransferer = transactional(wire[MoneyTransferer])\n\n   def transactional: Interceptor\n}\n```\n\nDuring tests, you can then use the `NoOpInterceptor`. In production code or integration tests, you can specify a real\ninterceptor, either by extending the `ProxyingInterceptor` trait, or by passing a function to the\n`ProxyingInterceptor` object:\n\n```scala\nobject MyApplication extends BusinessLogicModule {\n  lazy val tm = wire[TransactionManager]\n\n  lazy val transactional = ProxyingInterceptor { ctx =\u003e\n    try {\n      tm.begin()\n      val result = ctx.proceed()\n      tm.commit()\n\n      result\n    } catch {\n      case e: Exception =\u003e tm.rollback()\n    }\n  }\n}\n```\n\nThe `ctx` is an instance of an `InvocationContext`, and contains information on the parameters passed to the method,\nthe method itself, and the target object. It also allows to proceed with the invocation with the same or changed\nparameters.\n\nFor more general AOP, e.g. if you want to apply an interceptor to all methods matching a given pointcut expression,\nyou should use [AspectJ](http://eclipse.org/aspectj/) or an equivalent library. The interceptors that are implemented\nin MacWire correspond to annotation-based interceptors in Java.\n\n# Qualifiers\n\n\u003e [!NOTE]\n\u003e While the below works both in Scala 2 \u0026 Scala 3, in Scala 3, you can use the built-in\n\u003e [opaque types](https://docs.scala-lang.org/scala3/reference/other-new-features/opaques.html)\n\u003e instead.\n\nSometimes you have multiple objects of the same type that you want to use during wiring. Macwire needs to have some\nway of telling the instances apart. As with other things, the answer is: types! Even when not using `wire`, it may\nbe useful to give the instances distinct types, to get compile-time checking.\n\nFor that purpose Macwire includes support for tagging via [scala-common](https://github.com/softwaremill/scala-common),\nwhich lets you attach tags to instances to qualify them. This\nis a compile-time only operation, and doesn't affect the runtime. The tags are derived from\n[Miles Sabin's gist](https://gist.github.com/milessabin/89c9b47a91017973a35f).\n\nTo bring the tagging into scope, import `com.softwaremill.tagging._`.\n\nUsing tagging has two sides. In the constructor, when declaring a dependency, you need to declare what tag it needs\nto have. You can do this with the `_ @@ _` type constructor, or if you prefer another syntax `Tagged[_, _]`. The first\ntype parameter is the type of the dependency, the second is a tag.\n\nThe tag can be any type, but usually it is just an empty marker trait.\n\nWhen defining the available instances, you need to specify which instance has which tag. This can be done with the\n`taggedWith[_]` method, which returns a tagged instance (`A.taggedWith[T]: A @@ T`). Tagged instances can be used\nas regular ones, without any constraints.\n\nThe `wire` macro does not contain any special support for tagging, everything is handled by subtyping. For example:\n\n```scala\nclass Berry()\ntrait Black\ntrait Blue\n\ncase class Basket(blueberry: Berry @@ Blue, blackberry: Berry @@ Black)\n\nlazy val blueberry = wire[Berry].taggedWith[Blue]\nlazy val blackberry = wire[Berry].taggedWith[Black]\nlazy val basket = wire[Basket]\n```\n\nMultiple tags can be combined using the `andTaggedWith` method. E.g. if we had a berry that is both blue and black:\n\n```scala\nlazy val blackblueberry = wire[Berry].taggedWith[Black].andTaggedWith[Blue]\n```\n\nThe resulting value has type `Berry @ (Black with Blue)` and can be used both as a blackberry and as a blueberry.\n\n# Development\n\n## Debugging\n\nTo print debugging information on what MacWire does when looking for values, and what code is generated, set the\n`macwire.debug` system property. E.g. with SBT, start using `sbt -Dmacwire.debug`.\n\n## Future development - vote!\n\nTake a look at the [available issues](https://github.com/adamw/macwire/issues). If you'd like to see one developed\nplease vote on it. Or maybe you'll attempt to create a pull request?\n\n# Platform and version-specifics\n\n## Scala.js\n\nMacwire also works with [Scala.js](http://www.scala-js.org/). For an example, see here:\n[Macwire+Scala.js example](https://github.com/adamw/macwire/tree/master/examples/scalajs).\n\n## Scala3 support\n\nThe Scala 3 version is written to be compatible with Scala 2 where possible. Currently there are a few missing features:\n\n* [wire from parent scope](https://github.com/lampepfl/dotty/issues/13105)\n* [wire from imports](https://github.com/lampepfl/dotty/issues/12965)\n* [wire in pattern matching](https://github.com/softwaremill/macwire/issues/170)\n* [`wiredInModule`](https://github.com/softwaremill/macwire/issues/171) \n* [`@Module`](https://github.com/softwaremill/macwire/issues/172)\n\nFor full list of incompatibilities take a look at `tests/src/test/resources/test-cases` and `util-tests/src/test/resources/test-cases` .\n\n# Other\n\n## Commercial Support\n\nWe offer commercial support for MacWire and related technologies, as well as development services. [Contact us](https://softwaremill.com) to learn more about our offer!\n\n## Copyright\n\nCopyright (C) 2013-2025 SoftwareMill [https://softwaremill.com](https://softwaremill.com).\n\n","funding_links":[],"categories":["Table of Contents","IoC"],"sub_categories":["Modularization and Dependency Injection"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftwaremill%2Fmacwire","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoftwaremill%2Fmacwire","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftwaremill%2Fmacwire/lists"}