These are chat archives for fthomas/refined

30th
Jul 2016
Frank S. Thomas
@fthomas
Jul 30 2016 05:54
Here is a reproduction without using refined that throws the same error:
scala> import scala.tools.reflect.ToolBox
import scala.tools.reflect.ToolBox

scala> import scala.reflect.runtime.{universe => ru}
import scala.reflect.runtime.{universe=>ru}

scala> import shapeless.Witness
import shapeless.Witness

scala> val tb = scala.reflect.runtime.currentMirror.mkToolBox()
tb: scala.tools.reflect.ToolBox[reflect.runtime.universe.type] = scala.tools.reflect.ToolBoxFactory$ToolBoxImpl@5edff92f

scala> tb.eval(ru.reify(implicitly[Witness.Aux[Witness.`1`.T]]).tree)
res0: Any = shapeless.Witness$$anon$1@d2d16d3

scala> tb.eval(ru.reify(implicitly[ValueOf[Witness.`1`.T]]).tree)
scala.tools.reflect.ToolBoxError: reflective compilation has failed:

type mismatch;
 found   : ValueOf[Int]
 required: ValueOf[Int(1)]
Miles Sabin
@milessabin
Jul 30 2016 07:58
Is Witness essential here?
Frank S. Thomas
@fthomas
Jul 30 2016 08:56
No, it also fails with 1. The error is just different
Miles Sabin
@milessabin
Jul 30 2016 10:15
Gotcha ... thanks. I'll investigate.
Frank S. Thomas
@fthomas
Jul 30 2016 14:10
Btw, is it intended, that these two expressions have not the same type?
scala> valueOf[1]
res42: 1 = 1

scala> implicitly[ValueOf[1]].value
res43: Int = 1
Miles Sabin
@milessabin
Jul 30 2016 19:43
I'm afk atm ... what does final val foo = implicitly ... get you?
Frank S. Thomas
@fthomas
Jul 30 2016 21:26
scala> final val i = implicitly[ValueOf[1]].value
i: 1 = 1
Ok, so they have the same typed, but the type of .value is widened. That is different to Witness:
scala> implicitly[Witness.Aux[1]].value
res53: 1 = 1
Dale Wijnand
@dwijnand
Jul 30 2016 21:49
Because ValueOf#value return type is T while for valueOf it's T {}