Skip to content

Second parameter in implicit parameter list has uninstantiated type variables preventing implicit search from succeeding #11681

Closed
@japgolly

Description

@japgolly

Compiler version

3.0.0-RC1

Minimized code

import scala.collection.Factory

final case class Gen[+A]() {
  def take[C[X] <: Iterable[X], B](n: Int)(implicit w: A <:< C[B], f: Factory[B, C[B]]): Gen[C[B]] =
    Gen()
}

object Usage {
  def expected: Gen[List[Int]] =
    Gen[List[Int]]().take(3)
}

Output

[error] 10 |    Gen[List[Int]]().take(3)
[error]    |                            ^
[error]    |no implicit argument of type collection.Factory[Int, C[Int]] was found for parameter f of method take in class Gen.
[error]    |I found:
[error]    |
[error]    |    collection.Factory.arrayFactory[A]
[error]    |
[error]    |But method arrayFactory in object Factory does not match type collection.Factory[Int, C[Int]].
[error]    |
[error]    |The following import might fix the problem:
[error]    |
[error]    |  import collection.immutable.List.iterableFactory

Expectation

It should compile successfully (it does in Scala 2.13).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:typerbacklogNo work planned on this by the core team for the time being.itype:bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions