Evidence that no implicit T instance is available elsewhere.
The instance using the LowPriority[T] is ignored.
Allows to prioritize implicits, for example
trait TC[T] {
def prop: Boolean
}
object TC {
// TC[Int] available by default, with field `prop` trueimplicitval intTC: TC[Int] = new TC[Int] { def prop = true }
}
// extra `TC[T]`, with field `prop` falseimplicitdef extraTC[T](implicit ev: LowPriority[TC[T]]): TC[T] =
new TC[T] { def prop = false }
// Already available instance `intTC` is still found, because `extraTC[Int]` requires a// `LowPriority[TC[Int]]`, that will refuse to materialize (because `LowPriority` is able to// know about the already available `intTC`.)
assert(implicitly[TC[Int]].prop == true)
// `extraTC[String]` is found, as no other `TC[String]` can be found elsewhere
assert(implicitly[TC[String]].prop == false)
Evidence that no implicit
T
instance is available elsewhere.The instance using the
LowPriority[T]
is ignored.Allows to prioritize implicits, for example