Skip to content

No per-run caches in GenASM? #7422

@scabug

Description

@scabug

The compiler shouldn't have any global maps, and this one can trigger crashes in the presentation compiler. The smug message in the assertion is not very helpful for tracking down this issue, but I'd start by fixing the map.

I see this in GenASM.scala:155

  // Don't put this in per run caches. Contains entries for classes as well as members.
  val javaNameCache = new mutable.WeakHashMap[Symbol, Name]() ++= List(
    NothingClass        -> binarynme.RuntimeNothing,
    RuntimeNothingClass -> binarynme.RuntimeNothing,
    NullClass           -> binarynme.RuntimeNull,
    RuntimeNullClass    -> binarynme.RuntimeNull
  )

and crash (probably caused by two symbols for the same class, coming from different compiler runs):

ava.lang.AssertionError: assertion failed: how can getCommonSuperclass() do its job if different class symbols get the same bytecode-level internal name: scala/reflect/internal/Trees/Tree
	at scala.tools.nsc.backend.jvm.GenASM$JBuilder.javaName(GenASM.scala:547)
	at scala.tools.nsc.backend.jvm.GenASM$JBuilder.javaType(GenASM.scala:581)
	at scala.tools.nsc.backend.jvm.GenASM$JBuilder.javaType(GenASM.scala:587)
	at scala.tools.eclipse.JVMUtils$class.javaType(JVMUtils.scala:22)
	at scala.tools.eclipse.ScalaPresentationCompiler.javaType(ScalaPresentationCompiler.scala:36)
	at scala.tools.eclipse.javaelements.ScalaJavaMapper$class.mapParamTypeSignature(ScalaJavaMapper.scala:242)
	at scala.tools.eclipse.ScalaPresentationCompiler.mapParamTypeSignature(ScalaPresentationCompiler.scala:36)
	at scala.tools.eclipse.javaelements.ScalaStructureBuilder$StructureBuilderTraverser$DefOwner$$anonfun$13.apply(ScalaStructureBuilder.scala:659)
	at scala.tools.eclipse.javaelements.ScalaStructureBuilder$StructureBuilderTraverser$DefOwner$$anonfun$13.apply(ScalaStructureBuilder.scala:659)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
	at scala.collection.immutable.List.foreach(List.scala:318)
	at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
	at scala.collection.AbstractTraversable.map(Traversable.scala:105)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions