From 5a986a401ebc6baf8146e82aaa2057e5a6d46c88 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Tue, 24 Oct 2017 11:41:51 -0700 Subject: [PATCH 1/2] source-dependencies/value-class-underlying: fix test We were not testing what we thought we were testing before, because C used the name "x" which is also the name of the parameter we change in A, so when we changed A we were invalidating C too. Fixed by using a different name than "x" in C, which reveals that there is a bug somewhere since the test doesn't pass anymore. --- .../source-dependencies/value-class-underlying/C.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zinc/src/sbt-test/source-dependencies/value-class-underlying/C.scala b/zinc/src/sbt-test/source-dependencies/value-class-underlying/C.scala index 0c09ea764f..9a6a975330 100644 --- a/zinc/src/sbt-test/source-dependencies/value-class-underlying/C.scala +++ b/zinc/src/sbt-test/source-dependencies/value-class-underlying/C.scala @@ -1,6 +1,6 @@ object C { def main(args: Array[String]): Unit = { - val x = B.foo - println("x: " + x) // Need to use x in an expression to see if it crashes or not + val duck = B.foo + println("duck: " + duck) // Need to use duck in an expression to see if it crashes or not } } From 0215c84653f2df18c6a95cd362de7649112126fb Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Tue, 24 Oct 2017 15:52:01 -0700 Subject: [PATCH 2/2] Fix #442: Name hash of value class should include underlying type Quoting from 1e7e99e7e19e1c45f5a52aa31c399bd33c007582: If the underlying type of a value class change, its name hash doesn't change, but the name hash of change and since every class uses the name , 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). --- .../src/main/scala/xsbt/ExtractAPI.scala | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/compiler-bridge/src/main/scala/xsbt/ExtractAPI.scala b/internal/compiler-bridge/src/main/scala/xsbt/ExtractAPI.scala index 5b84b40e58..bb3991e9d3 100644 --- a/internal/compiler-bridge/src/main/scala/xsbt/ExtractAPI.scala +++ b/internal/compiler-bridge/src/main/scala/xsbt/ExtractAPI.scala @@ -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