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

ClassCastException: Trees$DocDef cannot be cast to Trees$ClassDef #9011

Closed
scabug opened this issue Nov 27, 2014 · 8 comments
Closed

ClassCastException: Trees$DocDef cannot be cast to Trees$ClassDef #9011

scabug opened this issue Nov 27, 2014 · 8 comments

Comments

@scabug
Copy link

scabug commented Nov 27, 2014

The exception happens indeed at a cast. It looks like a Docdef makes its way into namer.

      } else if (sym != null && sym.isClass && sym.isImplicit) {
        val owningInfo = sym.owner.info
        val existingDerivedSym = owningInfo.decl(sym.name.toTermName).filter(sym => sym.isSynthetic && sym.isMethod)
        existingDerivedSym.alternatives foreach (owningInfo.decls.unlink)
        enterImplicitWrapper(tree.asInstanceOf[ClassDef])
      }
      super.enterExistingSym(sym, tree)
java.lang.ClassCastException: scala.tools.nsc.ast.Trees$DocDef cannot be cast to scala.reflect.internal.Trees$ClassDef
	at scala.tools.nsc.interactive.InteractiveAnalyzer$InteractiveNamer$class.enterExistingSym(Global.scala:81)
	at scala.tools.nsc.interactive.InteractiveAnalyzer$$anon$7.enterExistingSym(Global.scala:40)
	at scala.tools.nsc.typechecker.Namers$Namer.standardEnterSym(Namers.scala:299)
	at scala.tools.nsc.typechecker.AnalyzerPlugins$class.pluginsEnterSym(AnalyzerPlugins.scala:422)
	at org.scalaide.core.internal.compiler.ScalaPresentationCompiler$$anon$1.pluginsEnterSym(ScalaPresentationCompiler.scala:85)
	at scala.tools.nsc.typechecker.Namers$Namer.enterSym(Namers.scala:274)
	at scala.tools.nsc.typechecker.Typers$Typer.enterSym(Typers.scala:1837)
	at scala.tools.nsc.typechecker.Typers$Typer.enterSyms(Typers.scala:1832)
	at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1873)
	at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:1744)
	at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5262)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5312)
	at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5349)
	at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5376)
	at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5323)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5327)
	at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5405)
	at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:3028)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$62.apply(Typers.scala:3132)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$62.apply(Typers.scala:3132)
	at scala.collection.immutable.List.loop$1(List.scala:173)
	at scala.collection.immutable.List.mapConserve(List.scala:189)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3132)
	at scala.tools.nsc.typechecker.Typers$Typer.typedPackageDef$1(Typers.scala:4969)
	at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5265)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5312)
	at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5349)
	at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5376)
	at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5323)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5327)
	at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5405)
	at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:3028)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$62.apply(Typers.scala:3132)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$62.apply(Typers.scala:3132)
	at scala.collection.immutable.List.loop$1(List.scala:173)
	at scala.collection.immutable.List.mapConserve(List.scala:189)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3132)
	at scala.tools.nsc.typechecker.Typers$Typer.typedPackageDef$1(Typers.scala:4969)
	at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5265)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5312)
	at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5349)
	at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5376)
	at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5323)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5327)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5401)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:102)
	at scala.tools.nsc.Global$GlobalPhase$$anonfun$applyPhase$1.apply$mcV$sp(Global.scala:428)
	at scala.tools.nsc.Global$GlobalPhase.withCurrentUnit(Global.scala:419)
	at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:428)
	at scala.tools.nsc.interactive.Global$TyperRun$$anonfun$applyPhase$1.apply(Global.scala:1222)
	at scala.tools.nsc.interactive.Global$TyperRun$$anonfun$applyPhase$1.apply(Global.scala:1222)
	at scala.reflect.internal.SymbolTable.enteringPhase(SymbolTable.scala:235)
	at scala.tools.nsc.interactive.Global$TyperRun.applyPhase(Global.scala:1222)
	at scala.tools.nsc.interactive.Global$TyperRun.typeCheck(Global.scala:1215)
	at scala.tools.nsc.interactive.Global.scala$tools$nsc$interactive$Global$$typeCheck(Global.scala:664)
	at scala.tools.nsc.interactive.Global$$anonfun$backgroundCompile$5$$anonfun$apply$8.apply(Global.scala:579)
	at scala.tools.nsc.interactive.Global$$anonfun$backgroundCompile$5.apply(Global.scala:575)
	at scala.tools.nsc.interactive.Global$$anonfun$backgroundCompile$5.apply(Global.scala:575)
	at scala.collection.TraversableLike$WithFilter$$anonfun$foreach$1.apply(TraversableLike.scala:778)
	at scala.collection.immutable.List.foreach(List.scala:381)
	at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:777)
	at scala.tools.nsc.interactive.Global.backgroundCompile(Global.scala:575)
	at scala.tools.nsc.interactive.PresentationCompilerThread.run(PresentationCompilerThread.scala:25)
@scabug
Copy link
Author

scabug commented Nov 27, 2014

Imported From: https://issues.scala-lang.org/browse/SI-9011?orig=1
Reporter: @dragos
Affected Versions: 2.11.5
See #8479

@scabug
Copy link
Author

scabug commented Dec 3, 2014

@retronym said:
This comment in TreeInfo rings true:

  // TODO these overrides, and the slow trickle of bugs that they solve (e.g. SI-8479),
  //      suggest that we should pursue an alternative design in which the DocDef nodes
  //      are eliminated from the tree before typer, and instead are modelled as tree
  //      attachments.

I take it this bug showed up in the IDE after mixing Interactive with ScalaDoc.

@scabug
Copy link
Author

scabug commented Dec 3, 2014

@retronym said:
Looking that the stack trace, it might be triggered by a documented member class.

@scabug
Copy link
Author

scabug commented Dec 3, 2014

@dragos said:
The surprising thing is that it won't happen every time. I couldn't reproduce it on a small example with documented inner classes..

@scabug
Copy link
Author

scabug commented Dec 3, 2014

@dragos said:
It seems to happen way more often when I have a documented implicit class (for example, when opening scala.reflect.api.Quasiquotes).

@scabug
Copy link
Author

scabug commented Dec 10, 2014

@dragos said:
Could we mark this a blocker for 2.11.5? It makes it very annoying to work on sources with quasiquotes/reflection. Let me know if I can help.

@scabug
Copy link
Author

scabug commented Dec 15, 2014

@retronym said:
@dragos could you please review and try out scala/scala#4205 ?

@scabug scabug closed this as completed Dec 23, 2014
@scabug
Copy link
Author

scabug commented Nov 25, 2016

@dragos said:
Fixed by Jason in c77b7a7

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