# Precedence of scoped type instances

**URL:** <https://softwaremill.community/t/precedence-of-scoped-type-instances/114>\
**Category:** macwire\
**Created:** [February 4, 2023, 10:53am UTC](https://softwaremill.community/t/precedence-of-scoped-type-instances/114 "2023-02-04T10:53:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![k0rn1](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/k0rn1/32/90_2.png) [@k0rn1](https://softwaremill.community/u/k0rn1)\
**Post date:** [February 4, 2023, 10:53am UTC](https://softwaremill.community/t/precedence-of-scoped-type-instances/114/1 "2023-02-04T10:53:47Z")

</div>

I have the following worksheet example:

```auto
import $dep.`com.softwaremill.macwire::util:2.5.8`
import $dep.`com.softwaremill.macwire::macros:2.5.8`
import com.softwaremill.macwire.wire

class Berry(var name: String)
case class Basket(berry: Berry)

lazy val blackberry: Berry = Berry("blackberry")

val basket: Basket = {
    lazy val raspberry: Berry = Berry("raspberry")
    wire[Basket]
}

println(basket.berry.name) // blackberry

```

The readme states:

> first it tries to find a unique value declared as a value in the current block

My understanding of this would be that the used instance should be the _raspberry_.

Could someone pls explain this to me?

Thanks

---

<div class="post-metadata">

**Author:** ![adamw](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/adamw/32/28_2.png) [@adamw](https://softwaremill.community/u/adamw)\
**Post date:** [February 6, 2023, 4:43pm UTC](https://softwaremill.community/t/precedence-of-scoped-type-instances/114/2 "2023-02-06T16:43:02Z")

</div>

This seems to work fine with scala 2, but doesn’t work with scala 3. Can you file an issue in [GitHub - softwaremill/macwire: Lightweight and Nonintrusive Scala Dependency Injection Library](https://github.com/softwaremill/macwire) ?
