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

print reflect.runtime.universe.Tree to scala source? #9316

Closed
scabug opened this issue May 15, 2015 · 2 comments
Closed

print reflect.runtime.universe.Tree to scala source? #9316

scabug opened this issue May 15, 2015 · 2 comments
Assignees

Comments

@scabug
Copy link

scabug commented May 15, 2015

I'd like to leverage quasiquoting to generate managed source. (Producing an implementation more easily inspected than macroimpls.)

import scala.reflect.runtime.universe._

scala> q"object Foo; case class Foo(x: Int)"
res7: reflect.runtime.universe.Tree =
{
  object Foo extends scala.AnyRef {
    def <init>() = {
      super.<init>();
      ()
    }
  };
  case class Foo extends scala.Product with scala.Serializable {
    <caseaccessor> <paramaccessor> val x: Int = _;
    def <init>(x: Int) = {
      super.<init>();
      ()
    }
  };
  ()
}

I know I can use show to get this, or use showRaw and get an even more AST-looking thing; but I want to generate valid scala source, something that could be fed back into toolbox.parse to reproduce the original tree.

@scabug
Copy link
Author

scabug commented May 15, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9316?orig=1
Reporter: @refried

@scabug
Copy link
Author

scabug commented May 15, 2015

@retronym said:
Use showCode, rather than show.

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

2 participants