Skip to content

Instantly share code, notes, and snippets.

@julienrf
Last active December 12, 2015 01:28
Show Gist options
  • Save julienrf/4691399 to your computer and use it in GitHub Desktop.
Save julienrf/4691399 to your computer and use it in GitHub Desktop.
object Ok {
trait Foo[A]
case class Bar(x: Int)
object Bar {
implicit class BarOps(bar: Foo[Bar]) {
val ok = "ok"
}
}
def usage(bar: Foo[Bar]) = bar.ok // Ok, the implicit conversion is found in the Bar companion object
}
// Same with Foo[A] being an abstract type member
trait Ko {
type Foo[A]
case class Bar(x: Int)
object Bar {
implicit class BarOps[A](bar: Foo[Bar]) {
val ko = "ko"
}
}
def usage(bar: Foo[Bar]) = bar.ko // Does not compile: “value ko is not a member of Ko.this.Foo[Ko.this.Bar]”
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment