- Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
area:transformitype:bugregressionThis worked in a previous version but doesn't anymoreThis worked in a previous version but doesn't anymore
Description
Compiler version
3.2.1
(3.2.0
also suffers from this, but not 3.1.3
)
Minimized code
(Edit: fully standalone reproduction in comment below)
Can be reproduced with Scala CLI. In Test.scala
:
//> using lib "com.lihaoyi:ammonite-cross-3.2.1-interp_2.13.10:2.5.5-17-df243e14" //> using lib "com.lihaoyi:ammonite-compiler_3.2.1:2.5.5-17-df243e14" //> using scala "3.2.1" import ammonite.compiler.* import ammonite.interp.* import ammonite.runtime.* import ammonite.util.* object Test { def main(args: Array[String]): Unit = { val frame = Frame.createInitial() new Interpreter( CompilerBuilder, Parsers, // this is the by-name parameter that triggers the class cast exception Printer(System.out, System.err, System.out, _ => (), _ => (), _ => ()), Storage.InMemory(), os.pwd, Ref(Colors.Default), getFrame = () => frame, createFrame = () => frame, replCodeWrapper = DefaultCodeWrapper, scriptCodeWrapper = DefaultCodeWrapper, alreadyLoadedDependencies = Nil ) {} // '{}' required to get the crash } }
I've not been able to reproduce that without using those Ammonite classes yet.
Output
Running it:
$ scala-cli Test.scala Exception in thread "main" java.lang.ClassCastException: class ammonite.compiler.Parsers$ cannot be cast to class scala.Function0 (ammonite.compiler.Parsers$ and scala.Function0 are in unnamed module of loader 'app') at Test$$anon$1.<init>(Test.scala:16) at Test$.main(Test.scala:25) at Test.main(Test.scala)
Expectation
No crash at runtime
Note that running this with Scala 3.1.3
requires slightly different dependencies. The header needs to be changed to
//> using lib "com.lihaoyi:ammonite-cross-3.1.3-interp_2.13.7:2.5.5-17-df243e14" //> using lib "com.lihaoyi:ammonite-compiler_3.1.3:2.5.5-17-df243e14" //> using scala "3.1.3"
Metadata
Metadata
Assignees
Labels
area:transformitype:bugregressionThis worked in a previous version but doesn't anymoreThis worked in a previous version but doesn't anymore