-
Notifications
You must be signed in to change notification settings - Fork 1.1k
"assertion failed: orphan parameter reference" when calling method with implicit parameters (one with and one without default value) #8424
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
Comments
maybe related to #5044 |
Is there anything in particular which is preventing you from minimizing it ? A good strategy is to replace the body of methods with |
I tried that way but the simplified code is compiled successfully 🤪 Edit: Oh. To clear, I am @ohze. |
Minimized: trait T
trait U
class Test(x: Any)(using val t: T = ???)(using val u: U = ???, disregard: Any = ???)
object Test {
def apply() = new Test(???)
}
The Note that this issue was filed against Dotty |
Update: tested on newer versions up through Output (click to expand)error when pickling type A
error when pickling tree A
error when pickling tree $conforms[A]
error when pickling tree disregard = $conforms[A]
error when pickling tree new Test(x$1)(using t$1)(using Test.$lessinit$greater$default$3(x$1)(t$1),
disregard = $conforms[A]
)
error when pickling tree {
val x$1: Nothing = ???
val t$1: Nothing = Test.$lessinit$greater$default$2(x$1)
new Test(x$1)(using t$1)(using Test.$lessinit$greater$default$3(x$1)(t$1),
disregard = $conforms[A]
)
}
error when pickling tree def apply(): Test =
{
val x$1: Nothing = ???
val t$1: Nothing = Test.$lessinit$greater$default$2(x$1)
new Test(x$1)(using t$1)(using Test.$lessinit$greater$default$3(x$1)(t$1),
disregard = $conforms[A]
)
}
error when pickling tree () extends Object() { this: Test.type =>
private def writeReplace(): AnyRef =
new scala.runtime.ModuleSerializationProxy(classOf[Test.type])
def $lessinit$greater$default$2(x: Any): Nothing = ???
def $lessinit$greater$default$3(x: Any)(using t: T): Nothing = ???
def $lessinit$greater$default$4(x: Any)(using t: T): Nothing = ???
def apply(): Test =
{
val x$1: Nothing = ???
val t$1: Nothing = Test.$lessinit$greater$default$2(x$1)
new Test(x$1)(using t$1)(using Test.$lessinit$greater$default$3(x$1)(t$1)
,
disregard = $conforms[A])
}
}
error when pickling tree @scala.annotation.internal.SourceFile("Main.scala") final module class Test$()
extends
Object() { this: Test.type =>
private def writeReplace(): AnyRef =
new scala.runtime.ModuleSerializationProxy(classOf[Test.type])
def $lessinit$greater$default$2(x: Any): Nothing = ???
def $lessinit$greater$default$3(x: Any)(using t: T): Nothing = ???
def $lessinit$greater$default$4(x: Any)(using t: T): Nothing = ???
def apply(): Test =
{
val x$1: Nothing = ???
val t$1: Nothing = Test.$lessinit$greater$default$2(x$1)
new Test(x$1)(using t$1)(using Test.$lessinit$greater$default$3(x$1)(t$1)
,
disregard = $conforms[A])
}
}
error when pickling tree package <empty> {
@scala.annotation.internal.SourceFile("Main.scala") class Test(x: Any)(using
t: T
)(using u: U, disregard: Any) extends Object() {
private[this] val x: Any
given val t: T
given val u: U
private[this] given val disregard: Any
}
final lazy module val Test: Test$ = new Test$()
@scala.annotation.internal.SourceFile("Main.scala") final module class Test$()
extends
Object() { this: Test.type =>
private def writeReplace(): AnyRef =
new scala.runtime.ModuleSerializationProxy(classOf[Test.type])
def $lessinit$greater$default$2(x: Any): Nothing = ???
def $lessinit$greater$default$3(x: Any)(using t: T): Nothing = ???
def $lessinit$greater$default$4(x: Any)(using t: T): Nothing = ???
def apply(): Test =
{
val x$1: Nothing = ???
val t$1: Nothing = Test.$lessinit$greater$default$2(x$1)
new Test(x$1)(using t$1)(using
Test.$lessinit$greater$default$3(x$1)(t$1)
, disregard = $conforms[A])
}
}
}
exception occurred while compiling Main.scala
java.lang.AssertionError: assertion failed: orphan parameter reference: TypeParamRef(A) while compiling Main.scala
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:300)
at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:175)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:599)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTpt(TreePickler.scala:327)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$38$$anonfun$1(TreePickler.scala:444)
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$4(TreePickler.scala:444)
at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:70)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:445)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:471)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$37$$anonfun$1(TreePickler.scala:437)
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$3(TreePickler.scala:437)
at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:70)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:438)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$9(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:70)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:478)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTreeUnlessEmpty(TreePickler.scala:330)
at dotty.tools.dotc.core.tasty.TreePickler.pickleDef$$anonfun$2(TreePickler.scala:345)
at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:70)
at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:347)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:561)
at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:371)
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:371)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$26(TreePickler.scala:587)
at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:70)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:588)
at dotty.tools.dotc.core.tasty.TreePickler.pickleDef$$anonfun$2(TreePickler.scala:342)
at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:70)
at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:347)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:563)
at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:371)
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:371)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$28(TreePickler.scala:597)
at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:70)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:597)
at dotty.tools.dotc.core.tasty.TreePickler.pickle$$anonfun$1(TreePickler.scala:766)
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:766)
at dotty.tools.dotc.transform.Pickler.run$$anonfun$3$$anonfun$2(Pickler.scala:69)
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:105)
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:105)
at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:296)
at scala.collection.immutable.List.map(List.scala:246)
at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:297)
at dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:110)
at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:185)
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:195)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:203)
at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:63)
at dotty.tools.dotc.Run.compileUnits(Run.scala:210)
at dotty.tools.dotc.Run.compileSources(Run.scala:147)
at dotty.tools.dotc.Run.compile(Run.scala:129)
at dotty.tools.dotc.Driver.doCompile(Driver.scala:38)
at dotty.tools.dotc.Driver.process(Driver.scala:195)
at dotty.tools.dotc.Driver.process(Driver.scala:164)
at dotty.tools.dotc.Driver.process(Driver.scala:176)
at dotty.tools.dotc.Driver.main(Driver.scala:203)
at dotty.tools.dotc.Main.main(Main.scala) |
P.S. I hope not to make a habit of minimizing others' 75KLOC Akka codebases submitted as bug reports. 😬 To all bug reporters: it is very helpful to attempt to minimize your code before submitting! This example shows it can be done! |
Alternatively: trait T
def test(x: Any)(using t: T = ???)(using u: T = ???, disregard: Any): Any = ???
val a = test(???) |
Amazing minimization @griggt 😅, in your last example we can go a bit further and still get the TreePickler crash: object Test {
def test(using u: String = ???, disregard: Any): Any = ???
val a = test
} The generated tree for val a: Any = Test.test(using Test.test$default$1, disregard = $conforms[A])
object Test {
def test(using u: Any = ???, disregard: Any): Any = ???
val a = test
} Now the generated tree for val a: Any = Test.test($conforms[Any], $conforms[Any]) as expected. |
It seems that the fix for this was in #13886. |
minimized code
:( I can't create a minimized code to reproduce the error.
Crash output (click arrow to expand)
The text was updated successfully, but these errors were encountered: