Skip to content

type inference via dependent typing breaks with varargs #11488

@lJoublanc

Description

@lJoublanc

Below is an reproduction of the problem, on both 2.12.8 and 2.13.0-M5.

scala> :paste
// Entering paste mode (ctrl-D to finish)

object Bug { 
  import java.nio._

    def apply[T,B](ts: T*)(implicit I: Implicit.Aux[T,B]): Either[T,B] = 
      Left(ts.head)

  trait Implicit[A] { type Out}

  object Implicit {
    type Aux[A, B] = Implicit[A] { type Out = B }
  }

  implicit def instance: Implicit.Aux[Double,java.nio.DoubleBuffer] = 
    new Implicit[Double] {
      type Out = DoubleBuffer
    }
}

// Exiting paste mode, now interpreting.

defined object Bug

scala> Bug(1.0,2.0)
res1: scala.util.Either[Double,this.Out] = Left(1.0)

scala> Bug(1.0)
res2: Either[Double,java.nio.DoubleBuffer] = Left(1.0)

Note that in the first case the type inference via the Aux pattern fails to work. It should return an Either[Double,DoubleBuffer]. However, if works just fine with a single argument.

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions