Skip to content

Commit

Permalink
Fix sbt#442: Name hash of value class should include underlying type
Browse files Browse the repository at this point in the history
Quoting from 1e7e99e:
    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 aca8dfa 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 Oct 24, 2017
1 parent 65a9bd9 commit d8ed7db
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/compiler-bridge/src/main/scala/xsbt/ExtractAPI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,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 d8ed7db

Please sign in to comment.