File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
compiler/src/dotty/tools/dotc/sbt
sbt-dotty/sbt-test/source-dependencies/value-class-underlying Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import StdNames._
1717import NameKinds .DefaultGetterName
1818import typer .Inliner
1919import typer .ErrorReporting .cyclicErrorMsg
20+ import transform .ValueClasses
2021import transform .SymUtils ._
2122import dotty .tools .io .Path
2223import 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
Original file line number Diff line number Diff line change 11object 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}
You can’t perform that action at this time.
0 commit comments