Skip to content

AssertionError: Orphan parameter reference #15428

Closed
@anatoliykmetyuk

Description

@anatoliykmetyuk

Compiler version

3.1.2

Minimized code

import reflect.Selectable.reflectiveSelectable

trait Foo:
  def f(): Long

def h() = k((_: Foo) => ???)

trait Bar[T]
given Bar[Foo] = ???

def k[T, Ptr <: { def f(): T }](function: Ptr => Int)(using alloc: Bar[Ptr]): T = ???

Output (click arrow to expand)

[info] compiling 1 Scala source to /Users/kmetiuk/Projects/GameDev/vulkan-tutorial/target/scala-3.1.2/classes ...
error when pickling type T
error when pickling type (): T
error when pickling type Object{f(): T}
error when pickling type Object{f(): T} & Foo
error when pickling tree (Object{f(): T} & Foo)
error when pickling tree k[Long, (Object{f(): T} & Foo)]
error when pickling tree k[Long, (Object{f(): T} & Foo)](
  {
    def $anonfun(_$1: Foo): Int = ???
    closure($anonfun)
  }
)
error when pickling tree k[Long, (Object{f(): T} & Foo)](
  {
    def $anonfun(_$1: Foo): Int = ???
    closure($anonfun)
  }
)(given_Bar_Foo)
error when pickling tree def h(): Long =
  k[Long, (Object{f(): T} & Foo)](
    {
      def $anonfun(_$1: Foo): Int = ???
      closure($anonfun)
    }
  )(given_Bar_Foo)
error when pickling tree () extends Object() { this: Ch06SwapChainCreationReprod$package.type =>
  private def writeReplace(): AnyRef =
    new scala.runtime.ModuleSerializationProxy(
      classOf[Ch06SwapChainCreationReprod$package.type]
    )
  def h(): Long =
    k[Long, (Object{f(): T} & Foo)](
      {
        def $anonfun(_$1: Foo): Int = ???
        closure($anonfun)
      }
    )(given_Bar_Foo)
  final lazy given val given_Bar_Foo: Bar[Foo] = ???
  def k[T >: Nothing <: Any,
    Ptr
       >: Nothing <:
        Object
          {
            def f(): T
          }
  ](function: Ptr => Int)(using alloc: Bar[Ptr]): T = ???
}
error when pickling tree @SourceFile("src/main/scala/Ch06SwapChainCreationReprod.scala") final module
  class
 Ch06SwapChainCreationReprod$package() extends Object() {
  this: Ch06SwapChainCreationReprod$package.type =>
  private def writeReplace(): AnyRef =
    new scala.runtime.ModuleSerializationProxy(
      classOf[Ch06SwapChainCreationReprod$package.type]
    )
  def h(): Long =
    k[Long, (Object{f(): T} & Foo)](
      {
        def $anonfun(_$1: Foo): Int = ???
        closure($anonfun)
      }
    )(given_Bar_Foo)
  final lazy given val given_Bar_Foo: Bar[Foo] = ???
  def k[T >: Nothing <: Any,
    Ptr
       >: Nothing <:
        Object
          {
            def f(): T
          }
  ](function: Ptr => Int)(using alloc: Bar[Ptr]): T = ???
}
error when pickling tree package <empty> {
  import reflect.Selectable.reflectiveSelectable
  final lazy module val Ch06SwapChainCreationReprod$package:
    Ch06SwapChainCreationReprod$package
   = new Ch06SwapChainCreationReprod$package()
  @SourceFile("src/main/scala/Ch06SwapChainCreationReprod.scala") final module
    class
   Ch06SwapChainCreationReprod$package() extends Object() {
    this: Ch06SwapChainCreationReprod$package.type =>
    private def writeReplace(): AnyRef =
      new scala.runtime.ModuleSerializationProxy(
        classOf[Ch06SwapChainCreationReprod$package.type]
      )
    def h(): Long =
      k[Long, (Object{f(): T} & Foo)](
        {
          def $anonfun(_$1: Foo): Int = ???
          closure($anonfun)
        }
      )(given_Bar_Foo)
    final lazy given val given_Bar_Foo: Bar[Foo] = ???
    def k[T >: Nothing <: Any,
      Ptr
         >: Nothing <:
          Object
            {
              def f(): T
            }
    ](function: Ptr => Int)(using alloc: Bar[Ptr]): T = ???
  }
}
[info] exception occurred while compiling /Users/kmetiuk/Projects/GameDev/vulkan-tutorial/src/main/scala/Ch06SwapChainCreationReprod.scala
java.lang.AssertionError: assertion failed: orphan parameter reference: TypeParamRef(T) while compiling /Users/kmetiuk/Projects/GameDev/vulkan-tutorial/src/main/scala/Ch06SwapChainCreationReprod.scala
[error] ## Exception when compiling 8 sources to /Users/kmetiuk/Projects/GameDev/vulkan-tutorial/target/scala-3.1.2/classes
[error] java.lang.AssertionError: assertion failed: orphan parameter reference: TypeParamRef(T)
[error] scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:286)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:155)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleMethodic$$anonfun$1(TreePickler.scala:294)
[error] dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:58)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleMethodic(TreePickler.scala:299)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:284)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:155)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleNewType$$anonfun$5(TreePickler.scala:243)
[error] dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:58)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:244)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:155)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleNewType$$anonfun$8(TreePickler.scala:261)
[error] dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:58)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:261)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:155)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:601)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTpt(TreePickler.scala:313)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$4$$anonfun$1(TreePickler.scala:432)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$4(TreePickler.scala:432)
[error] dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:58)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:433)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$3(TreePickler.scala:424)
[error] dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:58)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:426)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$3(TreePickler.scala:424)
[error] dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:58)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:426)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTreeUnlessEmpty(TreePickler.scala:316)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleDef$$anonfun$1(TreePickler.scala:332)
[error] dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:58)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:334)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:557)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:357)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:357)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$26(TreePickler.scala:583)
[error] dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:58)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:584)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleDef$$anonfun$1(TreePickler.scala:329)
[error] dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:58)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:334)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:559)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:357)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:357)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$29(TreePickler.scala:599)
[error] dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:58)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:599)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickle$$anonfun$1(TreePickler.scala:770)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:770)
[error] dotty.tools.dotc.transform.Pickler.run$$anonfun$1$$anonfun$1(Pickler.scala:69)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.transform.Pickler.run$$anonfun$1(Pickler.scala:106)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.transform.Pickler.run(Pickler.scala:106)
[error] dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:308)
[error] scala.collection.immutable.List.map(List.scala:246)
[error] dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:309)
[error] dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:111)
[error] dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:259)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1328)
[error] dotty.tools.dotc.Run.runPhases$1(Run.scala:270)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:278)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
[error] dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
[error] dotty.tools.dotc.Run.compileUnits(Run.scala:287)
[error] dotty.tools.dotc.Run.compileSources(Run.scala:220)
[error] dotty.tools.dotc.Run.compile(Run.scala:204)
[error] dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
[error] dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:88)
[error] dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:192)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:247)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:182)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:210)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:528)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:528)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:177)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:175)
[error] sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:461)
[error] sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
[error] sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:263)
[error] sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:416)
[error] sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:503)
[error] sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:403)
[error] sbt.internal.inc.Incremental$.apply(Incremental.scala:169)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:528)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:482)
[error] sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:420)
[error] sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error] sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2366)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2316)
[error] sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:30)
[error] sbt.internal.io.Retry$.apply(Retry.scala:46)
[error] sbt.internal.io.Retry$.apply(Retry.scala:28)
[error] sbt.internal.io.Retry$.apply(Retry.scala:23)
[error] sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:30)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2314)
[error] scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error] sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error] sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] sbt.Execute.work(Execute.scala:291)
[error] sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error] sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error] java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error] java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] java.lang.Thread.run(Thread.java:748)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions