Skip to content

Iterator bytecode field name is wrong in Scala 3.8.0 library #24994

@alexdupre

Description

@alexdupre

Apparently some classes in the published scala standard library, in particular some collections, have not been (re-)compiled correctly. The issue seems to have been triggered by a change in the Iterator object, from:

 private[this] val _empty: Iterator[Nothing]

to:

 private val _empty: Iterator[Nothing]

Some classes, like the Range, seem to still point to the previously generated bytecode field name.

Compiler version

3.8.0

Minimized code

//> using scala 3.8.0

@main def test = {
  val i = (1 to 1).grouped(1)
  println(i.next())
  println(i.next())
}

Output

Range 1 to 1
Exception in thread "main" java.lang.NoSuchFieldError: Class scala.collection.Iterator$ does not have member field 'scala.collection.Iterator scala$collection$Iterator$$_empty'
        at scala.collection.immutable.Range$$anon$3.next(Range.scala:562)
        at scala.collection.immutable.Range$$anon$3.next(Range.scala:553)
        at x$package$.test(x.scala:6)
        at test.main(x.scala:3)

Expectation

Range 1 to 1
Exception in thread "main" java.util.NoSuchElementException: next on empty iterator
        at scala.collection.Iterator$$anon$19.next(Iterator.scala:973)
        at scala.collection.Iterator$$anon$19.next(Iterator.scala:971)
        at scala.collection.immutable.Range$$anon$3.next(Range.scala:507)
        at scala.collection.immutable.Range$$anon$3.next(Range.scala:498)
        at x$package$.test(x.scala:6)
        at test.main(x.scala:3)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions