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

Comments

Projects
None yet
1 participant
@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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment