Skip to content

Commit 68463fb

Browse files
committed
Fix #442: Name hash of value class should include underlying type
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).
1 parent 5a986a4 commit 68463fb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

internal/compiler-bridge/src/main/scala/xsbt/ExtractAPI.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,16 @@ class ExtractAPI[GlobalType <: Global](
359359
* TODO: can we include hashes for parent classes instead? This seems a bit messy.
360360
*/
361361
private def mkStructureWithInherited(info: Type, s: Symbol): xsbti.api.Structure = {
362-
val ancestorTypes = linearizedAncestorTypes(info)
362+
val ancestorTypes0 = linearizedAncestorTypes(info)
363+
val ancestorTypes =
364+
if (s.isDerivedValueClass) {
365+
val underlying = s.derivedValueClassUnbox.tpe.finalResultType
366+
// The underlying type of a value class should be part of the name hash
367+
// of the value class (see the test `value-class-underlying`), this is accomplished
368+
// by adding the underlying type to the list of parent types.
369+
underlying :: ancestorTypes0
370+
} else
371+
ancestorTypes0
363372
val decls = info.decls.toList
364373
val declsNoModuleCtor = if (s.isModuleClass) removeConstructors(decls) else decls
365374
val declSet = decls.toSet

0 commit comments

Comments
 (0)