Skip to content

Instantly share code, notes, and snippets.

@cb372
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cb372/15053455fbf9700bd576 to your computer and use it in GitHub Desktop.
Save cb372/15053455fbf9700bd576 to your computer and use it in GitHub Desktop.
String concatenation is done very early
String concatenation happens before the tree is passed to your macro,
so you get passed a Literal(Constant("ab"))
scala> reify(() => "a" + "b")
res14: res0.universe.Expr[() => String] = Expr[() => java.lang.String]((() => "ab"))
This is not the case with other String ops.
I guess + is special because it's a Java operator, not a method on StringLike.
scala> reify(() => "a" * 5)
res15: res0.universe.Expr[() => String] = Expr[() => String]((() => Predef.augmentString("a").$times(5)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment