Skip to content

asTerm called on not-a-Term val when using the InteractiveDriver. #17916

Open
@ckipp01

Description

@ckipp01

Compiler version

3.3.1-RC1

To reproduce

You can reproduce this using Metals (latest nightly currently is 0.11.12+102-66fac3e0-SNAPSHOT) and a fresh clone of Dotty.

  1. git clone [email protected]:lampepfl/dotty.git
  2. cd dotty
  3. Open the build.sbt and import the build
  4. Once imported jump to messages.scala
    See the following in the logs
java.lang.AssertionError: assertion failed: asTerm called on not-a-Term val <none> while typechecking /Users/ckipp/Documents/scratch-workspace/dotty/compiler/src/dotty/tools/dotc/reporting/messages.scala
May 24, 2023 7:40:44 PM scala.meta.internal.pc.CompilerAccess handleError
SEVERE: assertion failed: asTerm called on not-a-Term val <none>
java.lang.AssertionError: assertion failed: asTerm called on not-a-Term val <none>
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
        at dotty.tools.dotc.core.Symbols$Symbol.asTerm(Symbols.scala:169)
        at dotty.tools.dotc.ast.tpd$.New(tpd.scala:512)
        at dotty.tools.dotc.core.Annotations$Annotation$Child$.makeChildLater$1(Annotations.scala:231)
        at dotty.tools.dotc.core.Annotations$Annotation$Child$.later$$anonfun$1(Annotations.scala:234)
        at dotty.tools.dotc.core.Annotations$LazyAnnotation.tree(Annotations.scala:140)
        at dotty.tools.dotc.core.Annotations$Annotation$Child$.unapply(Annotations.scala:242)
        at dotty.tools.dotc.typer.Namer.insertInto$1(Namer.scala:477)
        at dotty.tools.dotc.typer.Namer.addChild(Namer.scala:488)
        at dotty.tools.dotc.typer.Namer$Completer.register$1(Namer.scala:899)
        at dotty.tools.dotc.typer.Namer$Completer.registerIfChild$$anonfun$1(Namer.scala:908)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:333)
        at dotty.tools.dotc.typer.Namer$Completer.registerIfChild(Namer.scala:908)
        at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:811)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:174)
        at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:187)
        at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:189)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:390)
        at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2869)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2894)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2990)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3058)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3062)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3084)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3130)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2562)
        at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:2916)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2920)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2990)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3058)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3062)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3084)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3130)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2692)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2961)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2991)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3058)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3062)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3111)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3130)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2692)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2961)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2991)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3058)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3062)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3111)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3130)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2692)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2961)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2991)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3058)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3062)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3174)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:44)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$adapted$1(TyperPhase.scala:54)
        at scala.Function0.apply$mcV$sp(Function0.scala:42)
        at dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:437)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:54)
        at dotty.tools.dotc.typer.TyperPhase.runOn$$anonfun$3(TyperPhase.scala:88)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:333)
        at dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:88)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:247)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1321)
        at dotty.tools.dotc.Run.runPhases$1(Run.scala:263)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:271)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:280)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:280)
        at dotty.tools.dotc.Run.compileSources(Run.scala:195)
        at dotty.tools.dotc.interactive.InteractiveDriver.run(InteractiveDriver.scala:165)
        at scala.meta.internal.pc.MetalsDriver.run(MetalsDriver.scala:45)
        at scala.meta.internal.pc.PcCollector.<init>(PcCollector.scala:42)
        at scala.meta.internal.pc.PcDocumentHighlightProvider.<init>(PcDocumentHighlightProvider.scala:16)

This stems from when Metals is calling run on the InteractiveDriver as you can see in the stack trace.

This was originally reported in scalameta/metals#5268.

Expectation

When a tool is using the InteractiveDriver to run a file like this, we shouldn't be seeing assertion errors.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions