-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 can't find staging if started from sbt #7647
Comments
Still present. I have a the following in "ch.epfl.lamp" %% "dotty-staging" % ScalaVersion,
"ch.epfl.lamp" %% "dotty-library" % ScalaVersion, // this sure contains scalaShadowing Yet: sbt:loonyssh> console
scala> import scala.quoted._
| import scala.tasty._
scala> import scala.quoted.staging._
scala> def fn[T : Type](v : T) = println("ok")
def fn[T](v: T)(using evidence$1: quoted.Type[T]): Unit
scala> given scala.quoted.staging.Toolbox = scala.quoted.staging.Toolbox.make(getClass.getClassLoader)
def given_Toolbox: quoted.staging.Toolbox
scala> withQuoteContext { fn("foo") }
dotty.tools.dotc.MissingCoreLibraryException: Could not find package scalaShadowing from compiler core libraries.
Make sure the compiler core libraries are on the classpath.
at dotty.tools.dotc.core.Denotations$DenotationsBase.select$1(Denotations.scala:1212)
at dotty.tools.dotc.core.Denotations$DenotationsBase.recurSimple$1(Denotations.scala:1240)
at dotty.tools.dotc.core.Denotations$DenotationsBase.recur$1(Denotations.scala:1242)
at dotty.tools.dotc.core.Denotations$DenotationsBase.staticRef(Denotations.scala:1244)
at dotty.tools.dotc.core.Contexts$ContextBase.staticRef(Contexts.scala:664)
at dotty.tools.dotc.core.Symbols.requiredPackage(Symbols.scala:367)
at dotty.tools.dotc.core.Contexts$Context.requiredPackage(Contexts.scala:79)
at dotty.tools.dotc.core.Definitions.ScalaShadowingPackage(Definitions.scala:253)
... funny enough the following executes without an error scala> import _root_.scalaShadowing |
In 3.0.0-M3 the error became scala> import scala.quoted._
scala> import scala.quoted.staging._
scala> def fn[T : Type](v : T) = println("ok")
def fn[T](v: T)(implicit evidence$1: quoted.Type[T]): Unit
scala> given scala.quoted.staging.Toolbox = scala.quoted.staging.Toolbox.make(getClass.getClassLoader)
lazy val given_Toolbox: quoted.staging.Toolbox
scala> withQuotes { fn("foo") }
dotty.tools.dotc.MissingCoreLibraryException: Could not find package scala from compiler core libraries.
Make sure the compiler core libraries are on the classpath.
at dotty.tools.dotc.core.Denotations$.select$1(Denotations.scala:1234)
at dotty.tools.dotc.core.Denotations$.recurSimple$1(Denotations.scala:1262)
at dotty.tools.dotc.core.Denotations$.recur$1(Denotations.scala:1264)
at dotty.tools.dotc.core.Denotations$.staticRef(Denotations.scala:1266)
at dotty.tools.dotc.core.Symbols$.requiredPackage(Symbols.scala:850)
at dotty.tools.dotc.core.Definitions.ScalaPackageVal(Definitions.scala:202)
at dotty.tools.dotc.core.Definitions.ScalaPackageClass(Definitions.scala:205)
at dotty.tools.dotc.core.Definitions.AnyClass(Definitions.scala:260)
at dotty.tools.dotc.core.Definitions.syntheticScalaClasses(Definitions.scala:1693)
at dotty.tools.dotc.core.Definitions.syntheticCoreClasses(Definitions.scala:1709)
at dotty.tools.dotc.core.Definitions.init(Definitions.scala:1725)
at dotty.tools.dotc.core.Contexts$ContextBase.initialize(Contexts.scala:836)
at dotty.tools.dotc.core.Contexts$Context.initialize(Contexts.scala:548)
at dotty.tools.dotc.Run.rootContext(Run.scala:67)
at dotty.tools.dotc.Run.<init>(Run.scala:85)
at scala.quoted.staging.QuoteCompiler$ExprRun.<init>(QuoteCompiler.scala:105)
at scala.quoted.staging.QuoteCompiler.newRun(QuoteCompiler.scala:48)
at scala.quoted.staging.QuoteDriver.run(QuoteDriver.scala:39)
at scala.quoted.staging.Toolbox$$anon$1.run(Toolbox.scala:38)
at scala.quoted.staging.package$.withQuotes(staging.scala:42)
... 38 elided The issue is probably in ClasspathFromClassloader. We are probably not getting the full classpath from the classloader. |
is there a known fix for this? I'm also getting similar:
|
Whoever said "All the world's a staging" was wrong. |
Also now
|
I think you need
|
I have the following: it seems to find that, but is not finding Like I need to add something else to the class loader that I give to the runtime compiler? the bit about adding to lib dependencies is here: |
The classpath seems... reasonable: |
A CL might have C and D on the CP, but it may get loaded by delegation to parent. If C depends on D, the parent may not have D. I'll try to get some traction later. I've already done today's sudoku. |
just to make it unambiguous what I'm doing, here's a self-contained example: Welcome to Scala 3.1.1 (11.0.14, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala> import scala.quoted.*
scala> given staging.Compiler = staging.Compiler.make(getClass.getClassLoader)
lazy val given_Compiler: quoted.staging.Compiler
scala> def test(using Quotes): Expr[String] = Expr("hi!")
def test(using x$1: quoted.Quotes): quoted.Expr[String]
scala> staging.run { test }
dotty.tools.dotc.MissingCoreLibraryException: Could not find package scala from compiler core libraries.
Make sure the compiler core libraries are on the classpath. |
|
@som-snytt should I be using |
I don't know anything yet. |
bump |
I don't think there's a bug here, you need to pass in a classloader which contains the whole classpath. scala> import scala.quoted.*
scala> given staging.Compiler = staging.Compiler.make(classOf[staging.Compiler].getClassLoader)
lazy val given_Compiler: quoted.staging.Compiler
scala> def test(using Quotes): Expr[String] = Expr("hi!")
def test(using x$1: quoted.Quotes): quoted.Expr[String]
scala> staging.run { test }
val res0: String = hi! |
@smarter thanks! Using
|
minimized code
https://gist.github.com/Blaisorblade/c05f9f6f994732892caa24cae2eb6c3c
Works fine when starting from a REPL, not when invoking
<some-project>/console
expectation
It should work the same
Related dicussion
https://gitter.im/lampepfl/dotty?at=5de164a3d75ad3721d239f4e
The text was updated successfully, but these errors were encountered: