Skip to content

Commit 5dcc3d3

Browse files
Duhemmallanrenucci
authored andcommitted
1 parent fdb3caa commit 5dcc3d3

File tree

2 files changed

+14
-4
lines changed
  • compiler/src/dotty/tools/dotc/sbt
  • sbt-dotty/sbt-test/source-dependencies/value-class-underlying

2 files changed

+14
-4
lines changed

compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import StdNames._
1717
import NameKinds.DefaultGetterName
1818
import typer.Inliner
1919
import typer.ErrorReporting.cyclicErrorMsg
20+
import transform.ValueClasses
2021
import transform.SymUtils._
2122
import dotty.tools.io.Path
2223
import java.io.PrintWriter
@@ -254,8 +255,17 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
254255
val cinfo = csym.classInfo
255256

256257
val bases =
257-
try linearizedAncestorTypes(cinfo)
258-
catch {
258+
try {
259+
val ancestorTypes0 = linearizedAncestorTypes(cinfo)
260+
if (ValueClasses.isDerivedValueClass(csym)) {
261+
val underlying = ValueClasses.valueClassUnbox(csym).info.finalResultType
262+
// The underlying type of a value class should be part of the name hash
263+
// of the value class (see the test `value-class-underlying`), this is accomplished
264+
// by adding the underlying type to the list of parent types.
265+
underlying :: ancestorTypes0
266+
} else
267+
ancestorTypes0
268+
} catch {
259269
case ex: CyclicReference =>
260270
// See neg/i1750a for an example where a cyclic error can arise.
261271
// The root cause in this example is an illegal "override" of an inner trait
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
object C {
22
def main(args: Array[String]): Unit = {
3-
val x = B.foo
4-
println("x: " + x) // Need to use x in an expression to see if it crashes or not
3+
val duck = B.foo
4+
println("duck: " + duck) // Need to use duck in an expression to see if it crashes or not
55
}
66
}

0 commit comments

Comments
 (0)