Skip to content

Adding/removing/renaming a class always forces dependent source file to recompile #2319

@gkossakowski

Description

@gkossakowski

A.scala

// class Q

object A { val x = 3 }

B.scala

object B { val x = A.x }
  1. compile
  2. Uncomment line in A.scala.
  3. compile. Both sources are recompiled because Q introduces a change to the hash for <init> (in the compilation unit A.scala).

The underlying reason is that name hashing is tracking hashes for names at source file (compilation unit) level. The hash for <init> includes hashes for both A.<init> and Q.<init>. Therefore name hashing works well only when a member that is modified doesn't introduce any nested members. Therefore, it works for changes to val and def but not to class and object.

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