Skip to content

Type inference does not work on methods using dependent types and parameters with default value #7234

Open
@scabug

Description

@scabug

Here is a minimal test case that shows the problem:

trait Main {

  trait A {
    type B
  }

  trait C {
    def c(a: A, x: Int = 0)(b: a.B)
  }

  def c: C

  def ok(a: A)(b: a.B) = c.c(a, 42)(b)

  def fail(a: A)(b: a.B) = c.c(a)(b)

}

If I remove the x parameter default value, or explicitly fill its value, it works fine.
But compiling the above code produces the following error:

[error] /Volumes/Home/workspace/scala-dependent-types/src/main/scala/Main.scala:15: type mismatch;
[error]  found   : b.type (with underlying type a.B)
[error]  required: x$1.B
[error]   def fail(a: A)(b: a.B) = c.c(a)(b)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions