Created
May 27, 2015 14:05
-
-
Save tkawachi/18f73497a409574c056d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
case class A(i: Int) | |
case class B(i: Int) | |
case class C(i: Int) | |
class ImplicitTest { | |
object Implicits { | |
implicit val ia = A(1) | |
} | |
implicit def a2b(implicit a: A): B = new B(a.i) | |
implicit def b2c(implicit b: B): C = new C(b.i) | |
// import Implicits._ // -- (1) | |
// import ImplicitTest.ImplicitsInCompanion._ // -- (2) | |
// implicit val ial = A(1) // -- (3) | |
// (1) のみ -- コンパイルできる | |
// (2) のみ -- コンパイルできない | |
// (3) のみ -- コンパイルできる | |
// (1) と (3) -- コンパイルできない | |
// なにもなし -- コンパイルできない | |
implicitly[C] | |
} | |
object ImplicitTest { | |
object ImplicitsInCompanion { | |
implicit val iac = A(2) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment