Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
unkarjedy opened this issue Apr 21, 2022 · 3 comments
Closed

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

unkarjedy opened this issue Apr 21, 2022 · 3 comments
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label

Comments

@unkarjedy
Copy link
Contributor

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?

@unkarjedy unkarjedy added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 21, 2022
@unkarjedy
Copy link
Contributor Author

unkarjedy commented Apr 21, 2022

I accidently noticed this issue when upgrading tests for ScalaTest integration in IntelliJ to Scala 3 & ScalaTest 3.2.11.
(it's not critical to me, though)

Real example

lazy val scalatest_3_2_11 = project.settings(
  scalaVersion := "3.1.2",
  libraryDependencies ++= Seq(
    "org.scalatest" %% "scalatest" % "3.2.11"
  )
)
import org.scalatest._
import org.scalatest.wordspec._

class WordSpecTest extends AnyWordSpec {
  "empty 1" should {
    "ignore other tests" in {
      print(">>TEST: FAILED <<")
    }
  }
  
  "empty 2" should {
    //commented test body (for some reasons)
  }
}

image

This can happen when someone comments test body (for any reason)

@smarter
Copy link
Member

smarter commented Apr 21, 2022

This works on 3.1.3-RC2 so I guess it was fixed at the same time as #14699

@smarter smarter closed this as completed Apr 21, 2022
@unkarjedy
Copy link
Contributor Author

unkarjedy commented Apr 21, 2022

Indeed, thanks!

I thought that it was fixed in 3.1.2, cause I saw no error in the example from #14699
But turns out I just used the same file, and it showed the first error, hiding the error from the ticket =D

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label
Projects
None yet
Development

No branches or pull requests

2 participants