Skip to content

Overloading regression in Scala 3 (with implicit conversion) #15001

@unkarjedy

Description

@unkarjedy

similar to #14699

The following works in 2.13, but fails in Scala 3.

Compiler version

3.1.2

Minimized code

import scala.language.implicitConversions

trait StringShouldWrapperForVerb {
  def should(right: String): Unit = ???
  def should(right: => Unit): Unit = ???
}

object Example {
  implicit def convertToStringShouldWrapperForVerb(o: String): StringShouldWrapperForVerb = ???

  //ERROR
  "test 1" should {
  }
  
  //OK
  "test 2" should {
    ()
  }
  
  val s: StringShouldWrapperForVerb = ???
  s should {
    ()
  }

  s should {
  }
}

Scala 3 scastie
Scala 2 scastie

Output

None of the overloaded alternatives of method should in trait StringShouldWrapperForVerb with types
 (right: => Unit): Unit
 (right: String): Unit
match arguments (<nonsensical><notype></nonsensical>)

Expectation

No error, same as in Scala 2.13?

Metadata

Metadata

Assignees

No one assigned

    Labels

    itype:bugstat:needs triageEvery issue needs to have an "area" and "itype" label

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions