Skip to content

Implicit conversion never applied but influences type inference #12044

@mariogalic

Description

@mariogalic

reproduction steps

https://stackoverflow.com/questions/62415172/mere-presence-of-implicit-conversion-makes-the-program-compile-despite-never-bei/62426914

using Scala 2.13.2,

scala> class Bar
class Bar

scala> def f[F[_], A](v: F[A]) = v
def f[F[_], A](v: F[A]): F[A]

scala> implicit def barToList(b: Bar): List[Int] = List(42)
def barToList(b: Bar): List[Int]

scala> f(new Bar)
val res1: Any = Bar@56881196

problem

I would expect implicit conversion would result in

scala> f[List, Int](new Bar)
val res2: List[Int] = List(42)

where the following is inferred

F[_] = List
A = Int 

instead of actual

F[_] = Any
A = Nothing 

Examining the output of -Xprint:typer shows the following implicit conversion never happend

f(barToList(new Bar()))

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/)implicitinfertyper

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions