Skip to content

Commit

Permalink
Fix scala#442: Name hash of value class should include underlying type
Browse files Browse the repository at this point in the history
Quoting from 1e7e99e7e19e1c45f5a52aa31c399bd33c007582:
    If the underlying type of a value class change, its name hash
    doesn't change, but the name hash of <init> change and since every
    class uses the name <init>, we don't need to do anything special to
    trigger recompilations either

This was true until aca8dfac0b839cb8e93a7702f6ec2de09773b1b3 where we
started giving unique names to constructors. This broke the
value-class-underlying type but this wasn't noticed because the test was
broken in the same commit (and has now been fixed in the previous commit in
this PR).
  • Loading branch information
smarter committed Nov 8, 2017
1 parent 9a88ab6 commit 7e9ccc5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/scala/xsbt/ExtractAPI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,16 @@ class ExtractAPI[GlobalType <: Global](
* TODO: can we include hashes for parent classes instead? This seems a bit messy.
*/
private def mkStructureWithInherited(info: Type, s: Symbol): xsbti.api.Structure = {
val ancestorTypes = linearizedAncestorTypes(info)
val ancestorTypes0 = linearizedAncestorTypes(info)
val ancestorTypes =
if (s.isDerivedValueClass) {
val underlying = s.derivedValueClassUnbox.tpe.finalResultType
// The underlying type of a value class should be part of the name hash
// of the value class (see the test `value-class-underlying`), this is accomplished
// by adding the underlying type to the list of parent types.
underlying :: ancestorTypes0
} else
ancestorTypes0
val decls = info.decls.toList
val declsNoModuleCtor = if (s.isModuleClass) removeConstructors(decls) else decls
val declSet = decls.toSet
Expand Down

0 comments on commit 7e9ccc5

Please sign in to comment.