Lets say I have a unary evidence type constructor
class MyEvidence[T]
object MyEvidence {
//statically provable implicit/given values for various type arguments.
}
Now let us have urelated classes
trait MyClass { type MyType; val myVal :Box[MyType] }
class Box[T]
Lets us also assume that I not only know for a fact that a given MyEvidence[obj.MyType] exists or any obj :MyClass, but I can also construct it statically, without referencing obj, as a parameterless given value.
Problem:
- In code, somewhere I have an
obj :MyClass(such that I have no bounds onobj.MyType). - Lets assume I have an implicit conversion
Box[T] => Gizmo[T]if an implicitMyEvidence[T]exists (the use case for that evidence).
How can I provide the needed MyEvidence[obj.T], so that the conversion from point 2 exists?
I didn't minimize the question by replacing myVal :Box[MyType] with myVal :MyType (and the conversion to T => Gizmo[T] in case type inference works differently for type parameters and types of values (a hunch that the problem, as defined, may be easier).