Skip to content

Bad interaction between overloading, default arguments and implicit search #3352

Closed
@allanrenucci

Description

@allanrenucci

This code snippet does not compile with Dotty:

class Test {
  class Foo {
    def bar(x: String): Int = 1
  }

  implicit class FooOps(foo: Foo) {
    def bar(x: Int, y: Int = 2): Int = 2 // compiles with no default argument
  }

  def test(foo: Foo): Unit = {
    foo.bar(1)
  }
}
[info] Running dotty.tools.dotc.Main -d out Test.scala -classpath dotty-library_2.12-0.5.0-bin-SNAPSHOT-nonbootstrapped.jar
-- [E007] Type Mismatch Error: tests/allan/Test.scala:23:12 --------------------
23 |    foo.bar(1)
   |            ^
   |            found:    Int(1)
   |            required: String
   |

Maybe related to #3168

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