Skip to content

SortedMap#empty Fails At Runtime With NoSuchMethodError #9175

Closed
@adamgfraser

Description

@adamgfraser

Minimized code

import scala.collection.immutable.SortedMap

object Example extends App {
  
  val sortedMap = SortedMap("a" -> 1, "b" -> 2, "c" -> 3)
  val empty     = sortedMap.empty
  println(empty)
}

Output

java.lang.NoSuchMethodError: scala.collection.immutable.SortedMap.empty()Lscala/collection/Map;
	at Example$.<init>(main.scala:6)
	at Example$.<clinit>(main.scala)
	at Example.main(main.scala)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sbt.Run.invokeMain(Run.scala:115)
	at sbt.Run.execute$1(Run.scala:79)
	at sbt.Run.$anonfun$runWithLoader$4(Run.scala:92)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
	at sbt.util.InterfaceUtil$$anon$1.get(InterfaceUtil.scala:10)
	at sbt.TrapExit$App.run(TrapExit.scala:257)
	at java.lang.Thread.run(Thread.java:748)

Expectation

I would expect that since this method is in the API of the latest Scala collections it would work correctly. At the minimum if it did not work I would expect to get a compilation failure with a helpful error message.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions