Skip to content

MatchError in tree.show on scala.tasty.Reflection #8364

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

Closed
pavelfatin opened this issue Feb 24, 2020 · 1 comment · Fixed by #8450
Closed

MatchError in tree.show on scala.tasty.Reflection #8364

pavelfatin opened this issue Feb 24, 2020 · 1 comment · Fixed by #8450
Assignees

Comments

@pavelfatin
Copy link

pavelfatin commented Feb 24, 2020

Code (0.22.0-RC1)

val inspector = new TastyInspector {
  def processCompilationUnit(reflect: Reflection)(tree: reflect.Tree): Unit = {
    import reflect.{_, given}
    println(tree.show)
  }
}
inspector.inspect("", List("scala.tasty.Reflection"))

Output

scala.MatchError: AppliedType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class collection)),module immutable),Seq),List(TypeRef(ThisType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class scala)),module tasty),class Reflection)),type Term))) (of class dotty.tools.dotc.core.Types$CachedAppliedType) while compiling scala.tasty.Reflection
Exception in thread "main" scala.MatchError: AppliedType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class collection)),module immutable),Seq),List(TypeRef(ThisType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class scala)),module tasty),class Reflection)),type Term))) (of class dotty.tools.dotc.core.Types$CachedAppliedType)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printTypeTree(SourceCodePrinter.scala:1018)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printParamDef(SourceCodePrinter.scala:848)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printSeparated$14(SourceCodePrinter.scala:803)
	at scala.tasty.reflect.SourceCodePrinter$Buffer.printArgsDefs$$anonfun$1(SourceCodePrinter.scala:810)
...

SourceCodePrinter.scala

ref.tpe match {
  case tpe: TypeRef if tpe.typeSymbol == ctx.requiredClass("scala.annotation.internal.Repeated") =>
    val Types.Sequence(tp) = tpt.tpe // HERE

(and there are more errors besides the above line)

@pavelfatin
Copy link
Author

It would be great to test TastyInspector & SourceCodePrinter on all dotty-library.jar files as a part of CI, to ensure that TASTy Inspect / Reflect APIs are stable.

@nicolasstucki nicolasstucki self-assigned this Mar 6, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 6, 2020
@nicolasstucki nicolasstucki linked a pull request Mar 6, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants