Skip to content

Order of 'mc' synthetic methods is not deterministic #17330

Closed
@raboof

Description

@raboof

Compiler version

Tested with 3.2.2 and 3.3.1-RC1-bin-20230422-49879ac-NIGHTLY

Minimized code

import scala.collection.immutable

case object EmptyImmutableSeq extends immutable.Seq[Nothing] {
  override final def iterator = Iterator.empty
  override final def apply(idx: Int): Nothing = throw new java.lang.IndexOutOfBoundsException(idx.toString)
  override final def length: Int = 0
}

Output

Compiling this object several time and looking at the compiled output, the order of long apply$mcJI$sp(int), long apply$mcJJ$sp(long), long apply$mcJF$sp(float) etc is not deterministic.

Expectation

I would expect the order to be the same each time.

Making the compiler output deterministic helps quickly verifying two independently-built executables are equivalent, which can be a useful security property. It also may help with cache performance and for making it easier to find the 'meaningful' differences when comparing two class files that have more differences. See also Reproducible Builds and #7661 .

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions