Skip to content

Type inference of lambdas not working #11954

Open
@japgolly

Description

@japgolly

Note: Sorry for the poor title choice. I can't think of a concise way to describe this more accurately. Feel free to rename of course.

Compiler version

3.0.0-RC1

Minimized code

object X {

  class Component[P, S]
  trait Unmounted[P, M]
  trait Mounted[P, S]

  def unmounted[P, S, M](p: P, m: Component[P, S] => M): Unmounted[P, M] =
    ???

  def mounted[P, S](r: Component[P, S]): Mounted[P, S] =
    ???

  def test_KO[P, S](p: P): Unmounted[P, Mounted[P, S]] =
    unmounted(p, mounted) // error

  def test_OK[P, S](p: P): Unmounted[P, Mounted[P, S]] =
    unmounted(p, mounted[P, S]) // ok
}

Output

14 |    unmounted(p, mounted) // error
   |                 ^^^^^^^
   |                 Found:    X.Mounted[P, Any]
   |                 Required: X.Mounted[P, S]

Expectation

It should compile. Scala 2.x compiles without problem.

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