Skip to content

ClassCastException during REPL execution #20212

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

Closed
vasilmkd opened this issue Apr 17, 2024 · 2 comments
Closed

ClassCastException during REPL execution #20212

vasilmkd opened this issue Apr 17, 2024 · 2 comments

Comments

@vasilmkd
Copy link
Contributor

Compiler version

3.4.1

Minimized code

It is important to apply each of the definitions/expressions one by one, otherwise the exception is not reproducible.

scala> def g1(acc: Int)(h: (Int, Int) => Int): Int = h(acc, acc)
// def g1(acc: Int)(h: (Int, Int) => Int): Int

scala> def g2(acc: Int)(h: (=> Int, => Int) => Int): Int = h(acc, acc)
// def g2(acc: => Int)(h: (=> Int, => Int) => Int): Int

scala> g2(1)(_ + _)
// java.lang.ClassCastException: class java.lang.Integer cannot be cast to class scala.Function0 (java.lang.Integer is in module
// java.base of loader 'bootstrap'; scala.Function0 is in unnamed module of loader java.net.URLClassLoader @49798e84)
//   at scala.Function2.apply$mcIII$sp(Function2.scala:40)
//   at rs$line$2$.g2(rs$line$2:1)
//   ... 35 elided

Expectation

The result should be 2, instead of a ClassCastException being thrown.

Related IntelliJ IDEA ticket: https://youtrack.jetbrains.com/issue/SCL-22382/ClassNotFoundException-when-running-a-Scala-3-worksheet

@vasilmkd vasilmkd added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 17, 2024
@som-snytt
Copy link
Contributor

otherwise the exception is not reproducible.

oh man, hate it when that happens.

@Gedochao Gedochao added area:repl and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 18, 2024
@smarter
Copy link
Member

smarter commented Apr 25, 2024

Fixed in nightly builds by #19983

@smarter smarter closed this as completed Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants