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 fails on ClassDefs #8720

Closed
scabug opened this issue Jul 13, 2014 · 2 comments
Closed

showCode fails on ClassDefs #8720

scabug opened this issue Jul 13, 2014 · 2 comments

Comments

@scabug
Copy link

scabug commented Jul 13, 2014

I Don't seem to be able to use showCode on a ClassDef ever.

scala> import reflect.runtime.universe._ ; showCode(ClassDef(Modifiers(), TypeName("a"), Nil, Template(Nil, noSelfType, Nil)))
scala.MatchError: class a extends  (of class scala.reflect.internal.Trees$ClassDef)
  at scala.reflect.internal.Printers$CodePrinter.processTreePrinting(Printers.scala:752)
  at scala.reflect.internal.Printers$CodePrinter.printTree(Printers.scala:724)
  at scala.reflect.internal.Printers$TreePrinter$$anonfun$print$1.apply(Printers.scala:529)
  at scala.reflect.internal.Printers$TreePrinter$$anonfun$print$1.apply(Printers.scala:526)
  at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
  at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:35)
  at scala.reflect.internal.Printers$TreePrinter.print(Printers.scala:526)
  at scala.reflect.api.Printers$class.render(Printers.scala:185)
  at scala.reflect.api.Universe.render(Universe.scala:61)
  at scala.reflect.api.Printers$class.showCode(Printers.scala:221)
  at scala.reflect.api.Universe.showCode(Universe.scala:61)
@scabug
Copy link
Author

scabug commented Jul 13, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8720?orig=1
Reporter: Stew O'Connor (stew)
Affected Versions: 2.11.1

@scabug
Copy link
Author

scabug commented Oct 10, 2014

@gourlaysama said:
That's because that ClassDef is wrong: it isn't a trait and yet doesn't have a constructor. It can't exist.

scala> :pa
// Entering paste mode (ctrl-D to finish)

showCode(ClassDef(Modifiers(), TypeName("a"), Nil,
  Template(Nil, noSelfType, List(DefDef(Modifiers(),
    termNames.CONSTRUCTOR, List(), List(List()), 
    TypeTree(), Block(Literal(Constant(()))))))))


// Exiting paste mode, now interpreting.

res12: String = class a

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