Skip to content

Dependent function types do not play well with type inference #4130

Closed
@smarter

Description

@smarter
object Test {
  val f: (x: Int) => Int = x => x

  def id[A, B](x: (y: A) => B) = x

  id(f)
    // -- [E007] Type Mismatch Error: try/dep.scala:6:5 -------------------------------
    // 6 |  id(f)
    //   |     ^
    //   |     found:    (x: Int) => Int(Test.f)
    //   |     required: (y: Nothing) => Any
    //   |     

  id[Int, Int](f) // OK
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions