sbt / zinc

Scala incremental compiler library, used by sbt and other build tools
Apache License 2.0
334 stars 121 forks source link

Encode parent trait private members in `extraHash` to propagate `TraitPrivateMembersModified` across external dependency #1289

Closed Friendseeker closed 11 months ago

Friendseeker commented 11 months ago

This PR fixes #662

Cause of the issue

To determine if a class has API change TraitPrivateMembersModified, extraHash, which is a hash of private API of a trait is computed. Direct comparison on extraHash is used to determine if a trait has private member modified.

When we have the following dependency c.C -> b.B -> a.A, (c.C extends b.B, b.B extends a.A), for which c.C, b.B, a.A belongs to different projects, the dependencies are external, hence when A has private member modified, the following happens

Fix

When we compute extraHash for a child trait, use the parent traits' extraHash. Therefore, when parent has private members modified, child extraHash would change, hence child would have TraitPrivateMembersModified, propagating it.