Skip to content

Assertion failed: Orphan parameter reference TermParamRef for path-dependent type #15369

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
pweisenburger opened this issue Jun 4, 2022 · 0 comments · Fixed by #15390
Closed

Comments

@pweisenburger
Copy link
Contributor

Compiler version

3.1.2 and current main branch

Minimized code

trait Pack:
  type Reader

object PackTest extends Pack:
  type Reader

object Init:
  def get[P <: Pack](param: P): param.Reader = ???

trait Test:
  val pack: PackTest.type = PackTest
  val reader = Init.get[pack.type](pack)

Output (click arrow to expand)

error when pickling type param.type
error when pickling type param.Reader
error when pickling tree param.Reader
error when pickling tree val reader: param.Reader = Init.get[this.pack.type](this.pack)
error when pickling tree () extends Object {
  val pack: PackTest.type = PackTest
  val reader: param.Reader = Init.get[this.pack.type](this.pack)
}
error when pickling tree @SourceFile("Test.scala") trait Test() extends Object {
  val pack: PackTest.type = PackTest
  val reader: param.Reader = Init.get[this.pack.type](this.pack)
}
error when pickling tree package <empty> {
  @SourceFile("Test.scala") trait Test() extends Object {
    val pack: PackTest.type = PackTest
    val reader: param.Reader = Init.get[this.pack.type](this.pack)
  }
}
exception occurred while compiling Test.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: orphan parameter reference: TermParamRef(param)
java.lang.AssertionError: assertion failed: orphan parameter reference: TermParamRef(param) while compiling Test.scala
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:288)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:157)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleExternalRef$1(TreePickler.scala:197)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:219)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:157)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:603)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTpt(TreePickler.scala:315)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleDef$$anonfun$1(TreePickler.scala:332)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleDef$$anonfun$adapted$1(TreePickler.scala:336)
	at scala.Function0.apply$mcV$sp(Function0.scala:39)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:55)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:336)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:544)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:359)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.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:359)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$26(TreePickler.scala:585)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$adapted$24(TreePickler.scala:586)
	at scala.Function0.apply$mcV$sp(Function0.scala:39)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:55)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:586)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleDef$$anonfun$1(TreePickler.scala:331)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleDef$$anonfun$adapted$1(TreePickler.scala:336)
	at scala.Function0.apply$mcV$sp(Function0.scala:39)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:55)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:336)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:561)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:359)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.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:359)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$29(TreePickler.scala:601)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$adapted$27(TreePickler.scala:601)
	at scala.Function0.apply$mcV$sp(Function0.scala:39)
	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:55)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:601)
	at dotty.tools.dotc.core.tasty.TreePickler.pickle$$anonfun$1(TreePickler.scala:772)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.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:772)
	at dotty.tools.dotc.transform.Pickler.run$$anonfun$1$$anonfun$1(Pickler.scala:72)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.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:109)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.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:109)
	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:311)
	at scala.collection.immutable.List.map(List.scala:246)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:312)
	at dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:114)
	at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:225)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1328)
	at dotty.tools.dotc.Run.runPhases$1(Run.scala:236)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:244)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:253)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:253)
	at dotty.tools.dotc.Run.compileSources(Run.scala:186)
	at dotty.tools.dotc.Run.compile(Run.scala:170)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
	at dotty.tools.dotc.Driver.process(Driver.scala:195)
	at dotty.tools.dotc.Driver.process(Driver.scala:163)
	at dotty.tools.dotc.Driver.process(Driver.scala:175)
	at dotty.tools.dotc.Driver.main(Driver.scala:205)
	at dotty.tools.dotc.Main.main(Main.scala)

As can be seen in the output, the type of reader is param.Reader whereas, I assume, the type should be this.pack.Reader.

@pweisenburger pweisenburger added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 4, 2022
@dwijnand dwijnand added area:typer and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 6, 2022
@Kordyjan Kordyjan added this to the 3.2.0 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants