Skip to content

Commit

Permalink
Merge pull request #444 from smarter/fix-value-classes
Browse files Browse the repository at this point in the history
Fix #442: Name hash of value class should include underlying type
  • Loading branch information
dwijnand committed Nov 8, 2017
2 parents 73d0585 + 0215c84 commit 8050289
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
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 @@ -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
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit 8050289

Please sign in to comment.