Skip to content

REPL crash when inspecting symbols of quoted.Type in staged code #7017

Open
@liufengyun

Description

@liufengyun

minimized code

scala> import quoted._
scala> implicit def toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
scala> def fn[T : Type](v : T) = println("ok")
scala> object O
scala> withQuoteContext { withQuoteContext { given (qctx: QuoteContext) => import qctx.tasty._;  '[O.type].unseal.symbol.owner } }
Stack trace
java.lang.AssertionError: NoDenotation.owner
	at dotty.tools.dotc.core.SymDenotations$NoDenotation$.owner(SymDenotations.scala:2174)
	at dotty.tools.dotc.tastyreflect.ReflectionCompilerInterface.Symbol_owner(ReflectionCompilerInterface.scala:1511)
	at dotty.tools.dotc.tastyreflect.ReflectionCompilerInterface.Symbol_owner(ReflectionCompilerInterface.scala:1511)
	at scala.tasty.reflect.SymbolOps$SymbolAPI.owner(SymbolOps.scala:12)
	at rs$line$7$.$init$$$anonfun$1(rs$line$7:1)
	at scala.quoted.package$.dummyRun$1(package.scala:40)
	at scala.quoted.package$.withQuoteContext$$anonfun$1(package.scala:43)
	at dotty.tools.dotc.quoted.QuoteCompiler$QuotedFrontend.runOn$$anonfun$1(QuoteCompiler.scala:68)
	at scala.collection.immutable.List.flatMap(List.scala:338)
	at dotty.tools.dotc.quoted.QuoteCompiler$QuotedFrontend.runOn(QuoteCompiler.scala:82)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:158)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
	at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:198)
	at dotty.tools.dotc.Run.runPhases$5(Run.scala:170)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:178)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:65)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:185)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:125)
	at dotty.tools.dotc.quoted.QuoteCompiler$ExprRun.compileExpr(QuoteCompiler.scala:102)
	at dotty.tools.dotc.quoted.QuoteDriver.run(QuoteDriver.scala:36)
	at dotty.tools.dotc.quoted.ToolboxImpl$$anon$1.run(ToolboxImpl.scala:19)
	at scala.quoted.package$.withQuoteContext(package.scala:43)
	at rs$line$7$.<init>(rs$line$7:1)
	at rs$line$7$.<clinit>(rs$line$7)
	at rs$line$7.res1(rs$line$7)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at dotty.tools.repl.Rendering.$anonfun$3(Rendering.scala:57)
	at scala.Option.map(Option.scala:163)
	at dotty.tools.repl.Rendering.valueOf(Rendering.scala:57)
	at dotty.tools.repl.Rendering.renderVal(Rendering.scala:80)
	at dotty.tools.repl.ReplDriver.displayMembers$3$$anonfun$3(ReplDriver.scala:274)
	at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:237)
	at scala.collection.mutable.ResizableArray.foreach(ResizableArray.scala:62)
	at scala.collection.mutable.ResizableArray.foreach$(ResizableArray.scala:55)
	at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:49)
	at scala.collection.TraversableLike.map(TraversableLike.scala:237)
	at scala.collection.TraversableLike.map$(TraversableLike.scala:230)
	at scala.collection.AbstractTraversable.map(Traversable.scala:108)
	at dotty.tools.repl.ReplDriver.displayMembers$7(ReplDriver.scala:274)
	at dotty.tools.repl.ReplDriver.displayDefinitions$$anonfun$3$$anonfun$2(ReplDriver.scala:300)
	at scala.Option.map(Option.scala:163)
	at dotty.tools.repl.ReplDriver.displayDefinitions$$anonfun$1(ReplDriver.scala:300)
	at dotty.tools.dotc.core.Phases.atPhase$$anonfun$1(Phases.scala:35)
	at dotty.tools.dotc.core.Periods.atPhase(Periods.scala:25)
	at dotty.tools.dotc.core.Phases.atPhase(Phases.scala:35)
	at dotty.tools.dotc.core.Contexts$Context.atPhase(Contexts.scala:71)
	at dotty.tools.repl.ReplDriver.displayDefinitions(ReplDriver.scala:306)
	at dotty.tools.repl.ReplDriver.compile$$anonfun$2(ReplDriver.scala:230)
	at scala.util.Either.fold(Either.scala:191)
	at dotty.tools.repl.ReplDriver.compile(ReplDriver.scala:230)
	at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:182)
	at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:127)
	at dotty.tools.repl.ReplDriver.runUntilQuit$$anonfun$1(ReplDriver.scala:130)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput$$anonfun$2$$anonfun$1(ReplDriver.scala:143)
	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
	at scala.Console$.withErr(Console.scala:196)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput$$anonfun$1(ReplDriver.scala:143)
	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
	at scala.Console$.withOut(Console.scala:167)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:143)
	at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:130)
	at dotty.tools.repl.Main$.main(Main.scala:6)
	at dotty.tools.repl.Main.main(Main.scala)

diagnosis

A possible cause is that the VirtualDirectory used for output in REPL is not available in classpath when running the code.

This is minimized and reproduced from the failure in #7012 .

We should re-enable the test disabled in cd9b3f8 once this issue is fixed.

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