Skip to content

Bad interaction between -optimise and generic signature generation #3604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
odersky opened this issue Nov 29, 2017 · 1 comment
Closed

Bad interaction between -optimise and generic signature generation #3604

odersky opened this issue Nov 29, 2017 · 1 comment

Comments

@odersky
Copy link
Contributor

odersky commented Nov 29, 2017

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.

@allanrenucci
Copy link
Contributor

Closing as we removed local optimisations in #4799 and this is now properly tested (i.e. the test was moved to pos from pos-no-optimise)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants