A_1.scala:
class A(val self: Double) extends AnyVal
B_2.scala:
object B {
def foo: A = new A(1)
}
% ./bin/dotc A_1.scala
% ./bin/dotc B_2.scala
exception occurred while compiling B.scala
Exception in thread "main" java.lang.AssertionError: NoDenotation.owner
at dotty.tools.dotc.core.SymDenotations$NoDenotation.owner(SymDenotations.scala:1799)
at dotty.tools.dotc.ast.tpd$.ref(tpd.scala:346)
at dotty.tools.dotc.transform.Erasure$Boxing$.cast(Erasure.scala:230)
at dotty.tools.dotc.transform.Erasure$Boxing$$anonfun$unbox$2.apply(Erasure.scala:200)
at dotty.tools.dotc.transform.Erasure$Boxing$$anonfun$unbox$2.apply(Erasure.scala:175)
...
This does not happen if I manually create a companion in A_1.scala:
class A(val self: Double) extends AnyVal
object A