Skip to content

ADT derivation can produce not the same code between compilation #555

Description

@Romastyi

During Decoder/Codec derivation for ADT subclasses additional values declaration by indexes are using (here and here):

    val (transformedNameNames: List[TermName], transformedNameDefs: List[Tree]) = subclassList.zipWithIndex.map {
      case (s, i) =>
        val name = TermName(s"name$i")
        val value = transformName(nameOf(s))
        (name, q"private[this] val $name = $value")
    }.unzip

Despite that subclassList in both cases is defined as (here and here):

    // We don't _really_ care about the order but want to be sure its stable here.
    val subclassList: List[Symbol] = subclasses.toList

this implementation does not guarantee the same order (in fact, stable indexes) of such definitions between several compilations of the same code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions