Skip to content

Regression for typer in sageserpent-open/kineticmerge with implicit conversions #24255

@WojciechMazur

Description

@WojciechMazur

Based on the OpenCB failure in sageserpent-open/kineticmerge

Compiler version

Last good release: 3.7.3-RC1-bin-20250717-fb66af2-NIGHTLY
First bad release: 3.7.3-RC1-bin-20250718-42fdd76-NIGHTLY
Bisect points to 45f7ef6 / #23532

Minimized code

// https://github.com/scala/scala-collection-contrib/blob/main/src/main/scala/scala/collection/decorators/package.scala
object decorators {
  import scala.collection.generic.IsMap
  class MapDecorator[C, M <: IsMap[C]](coll: C)(implicit val map: M)
  implicit def mapDecorator[C](coll: C)(implicit map: IsMap[C]): MapDecorator[C, map.type] = ???
}
import decorators.mapDecorator // unused, required to reprouce


trait Eq[T]
trait Applicative[F[_]]
given Applicative[Option] = ???

trait Traverse[F[_]]:
  // context bound required to reproduce
  def traverse[G[_]: Applicative, A, B](fa: F[A])(f: A => G[B]): G[F[B]] 

object Traverse:
  def apply[F[_]]: Traverse[F] = ???

trait Segment[Element: Eq]:
  def fuseWith(another: Segment[Element])(
      elementFusion: (Element, Element) => Option[Element]
  ): Option[Segment[Element]] = ???

case class MergeResult[Element: Eq] private (segments: Seq[Segment[Element]]):
  def fuseWith(another: MergeResult[Element])(
      elementFusion: (Element, Element) => Option[Element]
  ): Option[MergeResult[Element]] =
    if segments.size != another.segments.size then None
    else
      Traverse[Seq]
        .traverse(segments.zip(another.segments))(_.fuseWith(_)(elementFusion))
        .map(MergeResult.apply) // error

Output

[error] No given instance of type Eq[Any] was found for a context parameter of method apply in object MergeResult
[error]         .map(MergeResult.apply) // error
[error]                               ^

Expectation

Should compile

Metadata

Metadata

Assignees

No one assigned

    Labels

    itype:bugregressionThis worked in a previous version but doesn't anymorestat:needs triageEvery issue needs to have an "area" and "itype" label

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions