Skip to content

Unpickling fails for pattern-bound types  #2437

Closed
@smarter

Description

@smarter

This fails -Ytest-pickler:

object Test {
  def foo(arg: Any) = arg match {
    case bla: List[t] =>
  }
}

Because unpickling fails:

Exception in thread "main" java.lang.AssertionError: assertion failed: Addr(85) Addr(98) Addr(100) BIND
        at scala.Predef$.assert(Predef.scala:170)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthType$1(TreeUnpickler.scala:268)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readType(TreeUnpickler.scala:330)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader$$anonfun$5.apply(TreeUnpickler.scala:233)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader$$anonfun$5.apply(TreeUnpickler.scala:233)

Indeed, we pickle three things:

      else if (sym is Flags.BindDefinedType) {
        registerDef(sym)
        writeByte(BIND)
        withLength {
          pickleName(sym.name)
          pickleType(sym.info)
          pickleRef()
        }
      }

Thus getting the tree:

    85:                 BIND(13) 26[t]
    88:                   TYPEBOUNDS(8)
    90:                     TYPEREF 27[Nothing]
    92:                       SHARED 52
    94:                     TYPEREF 19[Any]
    96:                       SHARED 52
    98:                   TYPEREFdirect 85

But we unpickle two things:

            case BIND =>
              val sym = ctx.newSymbol(ctx.owner, readName().toTypeName, BindDefinedType, readType())
              registerSym(start, sym)
              TypeRef.withFixedSym(NoPrefix, sym.name, sym)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions