Skip to content

Minor inconsistency with type aliases and implicit resolution. #2234

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
sir-wabbit opened this issue Apr 12, 2017 · 1 comment
Closed

Minor inconsistency with type aliases and implicit resolution. #2234

sir-wabbit opened this issue Apr 12, 2017 · 1 comment

Comments

@sir-wabbit
Copy link

The following doesn't compile:

  type Dummy[A] = A
  implicit def dummy[A]: Dummy[A] = null.asInstanceOf[A]
  def m(x: List[String])(implicit d: Dummy[String]) = "string"
  def m(x: List[Int])(implicit d: Dummy[Int]) = "int"

  m(List(1, 2, 3))
  m(List("a"))

But if we inline the type alias,

  type Dummy[A] = A
  implicit def dummy[A]: Dummy[A] = null.asInstanceOf[A]
  def m(x: List[String])(implicit d: String) = "string"
  def m(x: List[Int])(implicit d: Int) = "int"

  m(List(1, 2, 3))
  m(List("a"))

everything works as expected.

@OlivierBlanvillain
Copy link
Contributor

Thanks for reporting! I could minimize it further without implicits:

type Dummy[A] = A
def m(d: Dummy[String]) = ()
def m(d: Dummy[Int]) = ()
4 |  def m(d: Dummy[Int]) = ()
  |      ^
  |      method m is already defined as method m: (d: O.Dummy[String])Unit
  |       (the definitions have matching type signatures)

felixmulder added a commit that referenced this issue Apr 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants