Skip to content

'orphan parameter reference' when match type destructures a type alias with a bounded parameter #10242

Closed
@Jasper-M

Description

@Jasper-M

Minimized code

type Foo[A, B <: A] = A

type Bar[A] = A match {
  case Foo[String, x] => Unit
}

Output (click arrow to expand)

error when pickling type A
error when pickling type  <: A
error when pickling tree x @ _
error when pickling tree Foo[String, x @ _]
error when pickling tree case Foo[String, x @ _] => Unit
error when pickling tree A match 
  {
    case Foo[String, x @ _] => Unit
  }
error when pickling tree [A >: Nothing <: Any] =>> 
  A match 
    {
      case Foo[String, x @ _] => Unit
    }
error when pickling tree type Bar[A >: Nothing <: Any] = 
  A match 
    {
      case Foo[String, x @ _] => Unit
    }
error when pickling tree () extends Object(), _root_.scala.Serializable { this: rs$line$2.type =>
  private def writeReplace(): AnyRef = 
    new scala.runtime.ModuleSerializationProxy(classOf[rs$line$2.type])
  type Bar[A >: Nothing <: Any] = 
    A match 
      {
        case Foo[String, x @ _] => Unit
      }
}
error when pickling tree @scala.annotation.internal.SourceFile("rs$line$2") final module class rs$line$2$
  (
) extends Object(), _root_.scala.Serializable { this: rs$line$2.type =>
  private def writeReplace(): AnyRef = 
    new scala.runtime.ModuleSerializationProxy(classOf[rs$line$2.type])
  type Bar[A >: Nothing <: Any] = 
    A match 
      {
        case Foo[String, x @ _] => Unit
      }
}
error when pickling tree package <empty> {
  final lazy module val rs$line$2: rs$line$2$ = new rs$line$2$()
  @scala.annotation.internal.SourceFile("rs$line$2") final module class 
    rs$line$2$
  () extends Object(), _root_.scala.Serializable { this: rs$line$2.type =>
    private def writeReplace(): AnyRef = 
      new scala.runtime.ModuleSerializationProxy(classOf[rs$line$2.type])
    type Bar[A >: Nothing <: Any] = 
      A match 
        {
          case Foo[String, x @ _] => Unit
        }
  }
}
Exception in thread "main" java.lang.AssertionError: assertion failed: orphan parameter reference: TypeParamRef(A)
	at dotty.DottyPredef$.assertFail(DottyPredef.scala:17)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:279)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:154)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType$$anonfun$5(TreePickler.scala:246)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:49)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:248)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:154)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$20(TreePickler.scala:506)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:49)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:507)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$49$$anonfun$1(TreePickler.scala:588)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$31(TreePickler.scala:588)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:49)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:588)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$13(TreePickler.scala:478)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:49)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:478)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$50$$anonfun$1(TreePickler.scala:594)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$32(TreePickler.scala:594)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:49)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:595)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$34(TreePickler.scala:604)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:49)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:604)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTpt(TreePickler.scala:306)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleDef$$anonfun$2(TreePickler.scala:321)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:49)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:325)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:536)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:344)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:344)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$26(TreePickler.scala:560)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:49)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:561)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleDef$$anonfun$2(TreePickler.scala:320)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:49)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:325)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:536)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:344)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:344)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$28(TreePickler.scala:570)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:49)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:570)
	at dotty.tools.dotc.core.tasty.TreePickler.pickle$$anonfun$1(TreePickler.scala:736)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:736)
	at dotty.tools.dotc.transform.Pickler.run$$anonfun$9$$anonfun$8(Pickler.scala:63)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at dotty.tools.dotc.transform.Pickler.run$$anonfun$1(Pickler.scala:87)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at dotty.tools.dotc.transform.Pickler.run(Pickler.scala:87)
	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:309)
	at scala.collection.immutable.List.map(List.scala:246)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:310)
	at dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:91)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:181)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
	at dotty.tools.dotc.Run.runPhases$5(Run.scala:191)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:199)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:64)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:206)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:148)
	at dotty.tools.repl.ReplCompiler.runCompilationUnit(ReplCompiler.scala:153)
	at dotty.tools.repl.ReplCompiler.compile(ReplCompiler.scala:163)
	at dotty.tools.repl.ReplDriver.compile(ReplDriver.scala:233)
	at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:196)
	at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:129)
	at dotty.tools.repl.ReplDriver.runUntilQuit$$anonfun$1(ReplDriver.scala:132)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:151)
	at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:132)
	at dotty.tools.repl.Main$.main(Main.scala:6)
	at dotty.tools.repl.Main.main(Main.scala)

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions