Skip to content

Implicit resolution differs from Scala 2 in presence of GADTs #5469

Closed
@abgruszecki

Description

@abgruszecki

dotty compiles following code:

object O {
  sealed trait Box[T] { def value: T }
  final case class IntBox(value: Int) extends Box[Int]

  implicit def s1[T](implicit box: Box[T]): String = "generic: " + box.value
  implicit def s2(implicit box: Box[Int]): String = "specific: " + box.value

  def test[T](implicit box: Box[T]): String = box match {
    case IntBox(_) => implicitly[String]
  }
}

The implicit resolved in test is s1 (the generic one). scalac refuses to compile the code, saying that the implicit is ambiguous.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions