Skip to content

Assertion failed: "orphan parameter reference", inline transparent processing & given instances #15331

Closed
@p-pavel

Description

@p-pavel

Compiler version

3.1.2

Minimized code

  trait Composable[A,B]:
    def compose(a: A, b: B): Any

  trait Arrow {type Dom; type Codom}

  given composeArrows[A, Arr1 <: Arrow, Arr2 <: Arrow]: Composable[Arr1 {type Dom = A}, Arr2 {type Codom = A}] with
    def compose(a: Arr1 {type Dom = A}, b: Arr2 {type Codom = A}): Arrow {type Dom = b.Dom; type Codom = a.Codom} = ???

  object arr1 extends Arrow { type Dom = Int; type Codom = Int}
  object arr2 extends Arrow {type Dom = Int; type Codom = Float}

  // removing "transparent" alleviates the situation 
  inline transparent def compose[A, B](a: A, b: B)(using c: Composable[A,B]) = c.compose(a,b)
  val c = compose(arr2,arr1)

Output

scalac: Error: assertion failed: orphan parameter reference: TermParamRef(b)
java.lang.AssertionError: assertion failed: orphan parameter reference: TermParamRef(b)
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:286)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:155)
	at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:215)

......

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions