Skip to content

Name hashing: Methods with structural types in their signatures are not supported #1545

@gkossakowski

Description

@gkossakowski

Let's assume we have the following code structure:

// A.scala
object A {
  def x: Int = 3
}

// B.scala
object B {
  def onX(m: { def x: Int } ) = m.x
}

// C.scala
object C {
  def abc = B.onX(A)
}

Now, if we change A.scala to be

// A.scala
object A {
  def x: Byte = 3
}

then C.scala should get recompiled and error reported that A does not longer conform to structural type in onX method. However, the name hashing won't trigger recompilation f C.scala because only x name has been changed in A.scala and x is nowhere mentioned in C.scala.

This a limitation of name hashing algorithm which was designed with nominal types in mind. Fixing this might involve marking as used all names that appear in signatures of methods referred from a given source file.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions