Skip to content

Compatibility with implicit resolution #31

Open
@acjay

Description

@acjay

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions