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

ClassCastException: class scala.None$ cannot be cast to class scala.Some #245

Open
xuwei-k opened this issue Oct 16, 2024 · 0 comments
Open

Comments

@xuwei-k
Copy link
Contributor

xuwei-k commented Oct 16, 2024

build.sbt

libraryDependencies += "org.typelevel" %% "shapeless3-deriving" % "3.4.3"

scalaVersion := "3.5.1"

Main.scala

package example

import scala.annotation.StaticAnnotation

class A(x: Int) extends StaticAnnotation

case class Foo(
    a1: Int,
    @A(2) a2: Int,
    @A(3) a3: Int,
    @A(4) a4: Int,
    @A(5) a5: Int,
    @A(6) a6: Int,
    @A(7) a7: Int,
    @A(8) a8: Int,
    @A(9) a9: Int,
    @A(10) a10: Int,
    @A(11) a11: Int,
    @A(12) a12: Int,
    @A(13) a13: Int,
    @A(14) a14: Int,
    @A(15) a15: Int,
    @A(16) a16: Int,
    @A(17) a17: Int,
    @A(18) a18: Int,
    @A(19) a19: Int,
    @A(20) a20: Int,
    @A(21) a21: Int,
    @A(22) a22: Int,
    @A(23) a23: Int,
    @A(24) a24: Int
)

object Main {
  def main(args: Array[String]): Unit = {
    val x: Some[A] = shapeless3.deriving.Annotations[A, Foo].apply().head
  }
}

sbt run

[error] java.lang.ClassCastException: class scala.None$ cannot be cast to class scala.Some (scala.None$ and scala.Some are in unnamed module of loader sbt.internal.ScalaLibraryClassLoader @68cb9ead)
[error] 	at example.Main$.main(Main.scala:36)
[error] 	at example.Main.main(Main.scala)
[error] 	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
[error] 	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant