Closed
Description
Assuming #3602, if I compile tests/pos-no-optimise/escaping-refs.scala
with -optimise (and -uniqid for debugging), I get:
java.lang.AssertionError: assertion failed: bad parameter reference Bar#6061.this.B11#3739 at erasure
the parameter is type B11#3739 in class Bar#3738 but the prefix Bar#6061(Bar#6061.this)
does not define any corresponding arguments.
at scala.Predef$.assert(Predef.scala:219)
at dotty.tools.dotc.core.Types$NamedType.argDenot(Types.scala:1741)
at dotty.tools.dotc.core.Types$NamedType.fromDesignator$1(Types.scala:1669)
at dotty.tools.dotc.core.Types$NamedType.computeDenot(Types.scala:1690)
at dotty.tools.dotc.core.Types$NamedType.denotAt(Types.scala:1641)
at dotty.tools.dotc.core.Types$NamedType.denot(Types.scala:1630)
at dotty.tools.dotc.core.Types$NamedType.info(Types.scala:1624)
at dotty.tools.dotc.core.Types$Type.dealias(Types.scala:981)
at dotty.tools.dotc.core.Types$Type.dealias(Types.scala:1012)
at dotty.tools.dotc.core.Types$Type.widenDealias(Types.scala:1016)
at dotty.tools.dotc.transform.GenericSignatures$.boxedSig$1(GenericSignatures.scala:59)
at dotty.tools.dotc.transform.GenericSignatures$.argSig$1(GenericSignatures.scala:149)
at dotty.tools.dotc.transform.GenericSignatures$.$anonfun$javaSig0$8(GenericSignatures.scala:176)
at dotty.tools.dotc.transform.GenericSignatures$.$anonfun$javaSig0$8$adapted(GenericSignatures.scala:176)
at scala.collection.immutable.List.foreach(List.scala:389)
at dotty.tools.dotc.transform.GenericSignatures$.classSig$1(GenericSignatures.scala:176)
The problem seems to be that there is a reference Bar.this.B11
where B11
is a type parameter of a different Bar
. To track this down, I instrumented the apply
method in object TypeRef
in Types.scala
as follows:
object TypeRef {
/** Create a type ref with given prefix and name */
def apply(prefix: Type, desig: Designator)(implicit ctx: Context): TypeRef = {
desig match {
case sym: Symbol if sym.is(ClassTypeParam) && sym.name.toString == "B11" =>
prefix match {
case prefix: ThisType if prefix.cls.name.toString == "Bar" =>
assert(prefix.cls == sym.owner, i"$prefix . $desig")
case _ =>
}
case _ =>
}
...
This fails with an error in changeOwner
, called from simplify
.