Last active
December 12, 2015 01:28
-
-
Save julienrf/4691399 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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