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

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

Open
liufengyun opened this issue Aug 8, 2019 · 1 comment
Open
Labels
area:metaprogramming:reflection Issues related to the quotes reflection API itype:bug

Comments

@liufengyun
Copy link
Contributor

liufengyun commented Aug 8, 2019

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.

liufengyun added a commit to dotty-staging/dotty that referenced this issue Aug 11, 2019
The cause of the failure is reported in the following PR:

scala#7017

Once that issue is fixed, we should re-enable the following test

    scala> object O
    // defined object O
    scala> withQuoteContext { fn(O) }
    ok
@nicolasstucki
Copy link
Contributor

Updated version

scala> import quoted._
scala> import quoted.staging._
scala> implicit def toolbox: Toolbox = Toolbox.make(getClass.getClassLoader)
def toolbox: quoted.staging.Toolbox
scala> def fn[T : Type](v : T) = println("ok")
def fn[T](v: T)(implicit evidence$1: quoted.Type[T]): Unit
scala> object O
// defined object O
scala> withQuoteContext { (given qctx: QuoteContext) => import qctx.tasty.{_, given};  '[O.type].unseal.symbol.owner }
//

@nicolasstucki nicolasstucki added area:metaprogramming:reflection Issues related to the quotes reflection API and removed area:metaprogramming labels Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metaprogramming:reflection Issues related to the quotes reflection API itype:bug
Projects
None yet
Development

No branches or pull requests

2 participants