Preview:
object LowerCased:
  private def fromImpl(s: Expr[String])(using Quotes): Expr[LowerCased] =
    import quotes.reflect.*

    s.asTerm match
      case Inlined(_, _, Literal(StringConstant(str))) =>
        if LowerCased(str) == str then s
        else report.errorAndAbort(
          s"got a string which is not all lower case: $str")
      case _ => report.errorAndAbort(
        s"got a value which is not a constant string: ${s.show}")
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter