Skip to content

Bounds sharpened during implicit search leak between candidates #10708

@milessabin

Description

@milessabin

Discovered by @retronym: scala/scala-java8-compat#97 and minimized to,

trait BaseStream[T, S <: BaseStream[T, S]]
trait Stream[T] extends BaseStream[T, Stream[T]]
trait IntStream extends BaseStream[Integer, IntStream]

sealed trait SS[T, S <: BaseStream[_, S]]
object SSImplicits extends Low {
  implicit val IntValue: SS[Int, IntStream] = null
}
trait Low {
  implicit def anyStreamShape[T]: SS[T, Stream[T]] = null
}

import SSImplicits.{IntValue, anyStreamShape}

class Test {
  implicit def f[A, S <: BaseStream[_, S], CC](a: A)(implicit ss: SS[A, S]): S = ???

  // switch these lines and typechecking the body of `def x` fails in 2.13.x
  x
  y

  def x = f(0): IntStream
  def y = f[String, Stream[String], Vector[String]]("")

}

Identified as a regression caused by scala/scala#6140 ... see scala/scala#6140 (comment).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions