Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

showCode does not preserve backticks in function names #9057

Closed
scabug opened this issue Dec 22, 2014 · 3 comments
Closed

showCode does not preserve backticks in function names #9057

scabug opened this issue Dec 22, 2014 · 3 comments
Milestone

Comments

@scabug
Copy link

scabug commented Dec 22, 2014

scala> showCode(q"def `foo`() = 42")
res1: String = def foo() = 42

This is important for me, since I auto generate code overlapping with package names, e.g.

scala> def `java.lang.Object`() = 42
java$u002Elang$u002EObject: ()Int

scala> `java.lang.Object`()
res2: Int = 42

scala> showCode(q"def `java.lang.Object`() = 42")
res3: String = def java.lang.Object()  = 42

scala> toolBox.eval(toolBox.parse(showCode(q"def `java.lang.Object`() = 42")))
scala.tools.reflect.ToolBoxError: reflective compilation has failed:

'=' expected but '.' found.
illegal start of simple expression
  at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$ToolBoxGlobal.throwIfErrors(ToolBoxFactory.scala:316)
  at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$ToolBoxGlobal.parse(ToolBoxFactory.scala:291)
  at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$$anonfun$parse$1.apply(ToolBoxFactory.scala:417)
  at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$$anonfun$parse$1.apply(ToolBoxFactory.scala:414)
  at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$withCompilerApi$.liftedTree2$1(ToolBoxFactory.scala:355)
  at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$withCompilerApi$.apply(ToolBoxFactory.scala:355)
  at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl.parse(ToolBoxFactory.scala:414)
  ... 64 elided
@scabug
Copy link
Author

scabug commented Dec 22, 2014

Imported From: https://issues.scala-lang.org/browse/SI-9057?orig=1
Reporter: @JanBessai
Assignee: @JanBessai
Affected Versions: 2.11.4

@scabug
Copy link
Author

scabug commented Jan 7, 2015

@JanBessai said (edited on Jan 7, 2015 10:04:32 AM UTC):
Backticks don't influence calls to functions which do not require them, so it turns out this is just a problem with names including dots. Parts of language keywords etc. are already escaped appropriately by showCode.

A pull request including a fix and a test is on the way.

@scabug
Copy link
Author

scabug commented Jan 14, 2015

@gkossakowski said:
scala/scala#4234

@scabug scabug closed this as completed Jan 14, 2015
@scabug scabug added this to the 2.11.6 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant