propensive / contextual

Statically-checked string interpolation in Scala
https://soundness.dev/contextual/
251 stars 23 forks source link

Add support for implicit parameters for wrapped StringContext #33

Closed oskoi closed 7 years ago

oskoi commented 7 years ago

Fixes this error

<console>:16: error: exception during macro expansion:
scala.MatchError: contextual.examples.int.IntStringContext(scala.StringContext.apply("1"))(str).int (of class scala.reflect.internal.Trees$Select)
    at contextual.Macros.contextual(macros.scala:30)

       int"1"

Example of StringContext wrapper.

implicit class IntStringContext(sc: StringContext)(implicit str: String) {
  final val int = Prefix(IntParser, sc)
}
propensive commented 7 years ago

Looks like a nice, simple fix. Thank you!