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 cannot be cast to class scala.runtime.Nothing$ #22204

Open
jtjeferreira opened this issue Dec 12, 2024 · 0 comments
Open
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label

Comments

@jtjeferreira
Copy link
Contributor

Compiler version

Scala 3.6.2, 3.5.2, 3.3.4

Minimized code

import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.{
  JsonNodeFactory,
  ObjectNode,
  TextNode
}

val json: ObjectNode = JsonNodeFactory.instance.objectNode()

def foo(a: String): Unit = {
  a match {
    case "a" =>
      json.set("type", TextNode.valueOf("value"))
    case _ =>
      json.set("type", TextNode.valueOf("value"))

  }
}
foo("")

method set is a java method:

public <T extends JsonNode> T set(String propertyName, JsonNode value)

https://scastie.scala-lang.org/i507EyzXTdO1BM362YaOhA

Output

Caused by: java.lang.ClassCastException: class com.fasterxml.jackson.databind.node.ObjectNode cannot be cast to class scala.runtime.Nothing$

Expectation

That it does not crash like in scala2 https://scastie.scala-lang.org/gvqImCf7QeKBXahfClCZHA

@jtjeferreira jtjeferreira added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label
Projects
None yet
Development

No branches or pull requests

1 participant