Closed

Description
Compiler version
3.2.1
Minimized code
Open a Scala 3.2.1 REPL:
Welcome to Scala 3.2.1 (17.0.5, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala> new scala.concurrent.duration.DurationInt(5)
Output
Exception in thread "main" java.lang.ClassNotFoundException: package$DurationInt
at dotty.tools.repl.AbstractFileClassLoader.findClass(AbstractFileClassLoader.scala:51)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at dotty.tools.repl.AbstractFileClassLoader.loadClass(AbstractFileClassLoader.scala:57)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at dotty.tools.repl.Rendering.rewrapValueClass(Rendering.scala:127)
at dotty.tools.repl.Rendering.$anonfun$4(Rendering.scala:106)
at scala.Option.flatMap(Option.scala:283)
at dotty.tools.repl.Rendering.valueOf(Rendering.scala:106)
at dotty.tools.repl.Rendering.renderVal(Rendering.scala:149)
at dotty.tools.repl.ReplDriver.$anonfun$7(ReplDriver.scala:365)
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.repl.ReplDriver.extractAndFormatMembers$1(ReplDriver.scala:371)
at dotty.tools.repl.ReplDriver.renderDefinitions$$anonfun$2(ReplDriver.scala:403)
at scala.Option.map(Option.scala:242)
at dotty.tools.repl.ReplDriver.renderDefinitions(ReplDriver.scala:409)
at dotty.tools.repl.ReplDriver.compile$$anonfun$2(ReplDriver.scala:307)
at scala.util.Either.fold(Either.scala:189)
at dotty.tools.repl.ReplDriver.compile(ReplDriver.scala:323)
at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:248)
at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:168)
at dotty.tools.repl.ReplDriver.runUntilQuit$$anonfun$1(ReplDriver.scala:171)
at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:191)
at dotty.tools.repl.ReplDriver.runBody$$anonfun$1(ReplDriver.scala:179)
at dotty.tools.runner.ScalaClassLoader$.asContext(ScalaClassLoader.scala:80)
at dotty.tools.repl.ReplDriver.runBody(ReplDriver.scala:179)
at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:171)
at dotty.tools.repl.ReplDriver.tryRunning(ReplDriver.scala:133)
at dotty.tools.repl.Main$.main(Main.scala:7)
at dotty.tools.MainGenericRunner$.run$1(MainGenericRunner.scala:193)
at dotty.tools.MainGenericRunner$.process(MainGenericRunner.scala:270)
at dotty.tools.MainGenericRunner$.main(MainGenericRunner.scala:281)
at dotty.tools.MainGenericRunner.main(MainGenericRunner.scala)
Same error happens if new
is not used.
Expectation
Scala 3.2.0 REPL:
Welcome to Scala 3.2.0 (17.0.5, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala> new scala.concurrent.duration.DurationInt(5)
Output:
val res0: scala.concurrent.duration.package.DurationInt = 5
Although, the result is also weird, there's a mention of scala.concurrent.duration.package.DurationInt
, which is not the same fully qualified name. As far as I can tell, this behavior is consistent in Scala 3.1.3 too. I did not check older versions.
Edit:
Scala 2.13.10 reports the same value as:
val res0: concurrent.duration.DurationInt = scala.concurrent.duration.package$DurationInt@5
The mention of package
might just be down to the bytecode encoding and might be completely fine.