Scala Programming Language
  1. Scala Programming Language
  2. SI-5777

type conformance (or inference) difference between 2.9.2 and 2.10

    Details

      Description

      I happened across this while poking at SI-5340.

      
      trait Ring {
        trait E
      }
      
      class Poly[C <: Ring](val ring: C) extends Ring
      // This definition of Poly triggers the same failure on *both* versions
      // class Poly(val ring: Ring) extends Ring
      
      object BigInt extends Ring
      
      object MyApp {
        val r = new Poly(BigInt)
      
        // fail on 2.10, works on 2.9.2
        (null.asInstanceOf[BigInt.E] : r.ring.E)
      
        // works on both versions
        val r1 = new Poly[BigInt.type](BigInt)
        (null.asInstanceOf[BigInt.E] : r1.ring.E)
      
        // Oddly, -Xprint:typer reports that r and r1 have the same inferred type.
        //
        // private[this] val r: Poly[BigInt.type] = new Poly[BigInt.type](BigInt);
        // <stable> <accessor> def r: Poly[BigInt.type] = MyApp.this.r;
        // (null.asInstanceOf[BigInt.E]: MyApp.r.ring.E);
        // private[this] val r1: Poly[BigInt.type] = new Poly[BigInt.type](BigInt);
        // <stable> <accessor> def r1: Poly[BigInt.type] = MyApp.this.r1;
        // (null.asInstanceOf[BigInt.E]: MyApp.r1.ring.E)
      
        // diff typer-2.9.2.txt typer-2.10.txt
        // ...
        // ---
        // >   object MyApp extends scala.AnyRef {
        // >     def <init>(): MyApp.type = {
        // >       MyApp.super.<init>();
        // 30c30
        // <     scala.this.Predef.implicitly[<:<[BigInt.E,MyApp.r.ring.E]](scala.this.Predef.conforms[BigInt.E]);
        // ---
        // >     scala.this.Predef.implicitly[<:<[BigInt.E,MyApp.r.ring.E]]();
      }
      

        Activity

        Hide
        Paul Phillips added a comment -

        Changed between M2 and M3. I strongly suspect virtpatmat.

        Show
        Paul Phillips added a comment - Changed between M2 and M3. I strongly suspect virtpatmat.
        Hide
        Paul Phillips added a comment -

        Oh, this is only five weeks ago? Oops, I strongly suspect this then: a7f68ce32c

        Show
        Paul Phillips added a comment - Oh, this is only five weeks ago? Oops, I strongly suspect this then: a7f68ce32c
        Hide
        Paul Phillips added a comment -

        Right, I removed the code which special cased inference for module classes so that "BigInt.type" would be inferred, because in theory it was no longer necessary as subtyping itself now captured the essence. But it seems there was a gap.

        Show
        Paul Phillips added a comment - Right, I removed the code which special cased inference for module classes so that "BigInt.type" would be inferred, because in theory it was no longer necessary as subtyping itself now captured the essence. But it seems there was a gap.
        Hide
        Paul Phillips added a comment -

        I got it, thanks for finding.

        Show
        Paul Phillips added a comment - I got it, thanks for finding.
        Hide
        Paul Phillips added a comment -

        e8e88f785d

        Show
        Paul Phillips added a comment - e8e88f785d
        Hide
        Jason Zaugg added a comment -

        Just glad that my proclivity for stumbling over things can be put to good use.

        Show
        Jason Zaugg added a comment - Just glad that my proclivity for stumbling over things can be put to good use.

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Jason Zaugg
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development