Skip to content
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

weird fail in extension method resolution #9588

Open
scabug opened this issue Dec 12, 2015 · 3 comments
Open

weird fail in extension method resolution #9588

scabug opened this issue Dec 12, 2015 · 3 comments
Labels
fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) typer
Milestone

Comments

@scabug
Copy link

scabug commented Dec 12, 2015

This works:

class Bar[A] { 
  def foo(x: collection.GenTraversableOnce[A]) = 3 
}
implicit class BarOps[A](b: Bar[A]) { 
  def foo[F[_]](f: F[Int]) = 4
}
(new Bar).foo(List(3)) // returns 3
(new Bar).foo(scalaz.IList(3)) // returns 4

This doesn't work:

implicit class BarOps[A](b: Bar[A]) { 
  def foo[F[_]](f: F[A]) = 4 // changed Int to A
}
(new Bar).foo(scalaz.IList(3)) // error: type mismatch;
//   found : scalaz.IList[Int]
//   required: scala.collection.GenTraversableOnce[?]
@scabug
Copy link
Author

scabug commented Dec 12, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9588?orig=1
Reporter: @refried
Affected Versions: 2.11.7, 2.12.0-M3
See #9523

@scabug
Copy link
Author

scabug commented Jan 19, 2016

@szeiger said:
Standalone repro:

  trait B[X]

  class F[X] { 
    def foo(x: Int) = 3 
    def bar(x: Int) = 3 
  }
  implicit class FooOps[E](b: F[E]) { 
    def foo[G[_]](f: G[Int]) = 4
  }
  implicit class BarOps[E](b: F[E]) { 
    def bar[G[_]](f: G[E]) = 4
    def baz[G[_]](f: G[E]) = 4
  }

  (new F[Int]).foo(null: B[Int]) // ok
  (new F[Int]).bar(null: B[Int]) // type mismatch
  (new F[Int]).baz(null: B[Int]) // ok

@scabug
Copy link
Author

scabug commented Jan 21, 2016

@szeiger said:
Possibly a duplicate of #9523

@scabug scabug added the typer label Apr 7, 2017
@scabug scabug added this to the Backlog milestone Apr 7, 2017
@pabloazul pabloazul added the fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) label Nov 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) typer
Projects
None yet
Development

No branches or pull requests

2 participants