@@ -5,16 +5,13 @@ import scala.language.implicitConversions
55
66case  class  Xml (parts : String , args : List [Any ])
77
8- //  Ideally should be an implicit class but the implicit conversion
9- //  has to be a inline method
10- class  XmlQuote (val  ctx :  StringContext ) {
11-   inline  def  xml (args : =>  Any * ):  Xml  =  ~ XmlQuote .impl('(this),  ' (args))
12- }
13- 
148object  XmlQuote  {
15-   implicit  inline  def  XmlQuote (ctx : StringContext ):  XmlQuote  =  new  XmlQuote (ctx)
169
17-   def  impl (receiver : Expr [XmlQuote ], args : Expr [Seq [Any ]])
10+   implicit  class  SCOps (ctx : StringContext ) {
11+     inline  def  xml (args : =>  Any * ):  Xml  =  ~ XmlQuote .impl('(this),  ' (args))
12+   }
13+ 
14+   def  impl (receiver : Expr [SCOps ], args : Expr [Seq [Any ]])
1815          (implicit  tasty : Tasty ):  Expr [Xml ] =  {
1916    import  tasty ._ 
2017    import  Term ._ 
@@ -41,17 +38,21 @@ object XmlQuote {
4138      case  _ =>  false 
4239    }
4340
44-     //  _root_.scala.StringContext.apply([p0, ...]: String*)
41+     def  isSCOpsConversion (tree : Term ) = 
42+       tree.symbol.fullName ==  " XmlQuote$.SCOps" 
43+ 
44+     def  isStringContextApply (tree : Term ) = 
45+       tree.symbol.fullName ==  " scala.StringContext$.apply" 
46+ 
47+     //  XmlQuote.SCOps(StringContext.apply([p0, ...]: String*)
4548    val  parts  =  receiver.toTasty.underlyingArgument match  {
46-       case  Apply (
47-             Select (New (_), _, _),
48-             List (
49-               Apply (
50-                 Select (Select (Select (Ident (" _root_"  ), " scala"  , _), " StringContext"  , _), " apply"  , _),
51-                 List (Typed (Repeated (values), _))))) if  values.forall(isStringConstant) => 
49+       case  Apply (conv, List (Apply (fun, List (Typed (Repeated (values), _)))))
50+           if  isSCOpsConversion(conv) && 
51+              isStringContextApply(fun) && 
52+              values.forall(isStringConstant) => 
5253        values.collect { case  Literal (Constant .String (value)) =>  value }
5354      case  tree => 
54-         abort(s " String literal expected, but  $tree found " )
55+         abort(s " String literal expected, but  ${ tree.show}  found " )
5556    }
5657
5758    //  [a0, ...]: Any*
0 commit comments