Skip to content

implicit <:< in combination with a default implicit parameter fails to compile #10497

Open
@Avasil

Description

@Avasil

Minimized code

trait Foo[+A] {
  def foo[B](implicit ev: A <:< Foo[B], s: Int = 0) = ???

  def bar(a: Foo[Foo[Int]]) = a.foo
}

Output

[error] 54 |  def bar(a: Foo[Foo[Int]]) = a.foo
[error]    |                                   ^
[error]    |no implicit argument of type Int was found for parameter s of method foo in trait Foo

Expectation

My expectation is to compile.

I have experienced the issue on Scala 3.0.0-M1.
It compiles successfully on Scala 2.

It seems to work if foo is called with type parameter, i.e. a.foo[Int] but it still fails if the default parameter would be Set[B] = Set.empty instead of Int.

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