Open
Description
I'm trying to capture the literal floating-point number that a person used in a data structure:
scala> trait Capture { def text: String }
defined trait Capture
scala> implicit class DoubleCapture(source: sourcecode.Text[Double]) extends Capture { def text = source.source }
defined class DoubleCapture
^
scala> val x: Capture = 5.0
<console>:49: error: type mismatch;
found : Double(5.0)
required: Capture
val x: Capture = 5.0
If DoubleCapture
takes a Double
, this works fine. But I don't want the Double
itself, what I really want is the string representation from the code itself. I was hoping I could use sourcecode.Text
to do this, but it doesn't seem to work.
Metadata
Metadata
Assignees
Labels
No labels