Precedence of scoped type instances

I have the following worksheet example:

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")

println( // 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?


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 ?

1 Like