Created
January 21, 2019 19:23
-
-
Save drdozer/ef91d0ff273dacb005543ecac4477c6b to your computer and use it in GitHub Desktop.
extension methods visibility
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
[info] Compiling 1 Scala source to /home/nmrp3/devel/turingatemyhamster/test_extension_methods/target/scala-0.12/classes ... | |
[warn] -- [E128] Potential Issue Warning: /home/nmrp3/devel/turingatemyhamster/test_extension_methods/src/main/scala/Main.scala:27:14 | |
[warn] 27 | implicitly[Foo.type] | |
[warn] | ^^^^^^^^^^^^^^^^^^^^ | |
[warn] |A pure expression does nothing in statement position; you may be omitting necessary parentheses | |
[error] -- [E008] Member Not Found Error: /home/nmrp3/devel/turingatemyhamster/test_extension_methods/src/main/scala/Main.scala:32:16 | |
[error] 32 | println(432.nose) | |
[error] | ^^^^^^^^ | |
[error] | value nose is not a member of Int - did you mean Int(432).+? | |
[warn] one warning found | |
[error] one error found | |
[error] (Compile / compileIncremental) Compilation failed | |
[error] Total time: 1 s, completed 21 Jan 2019, 19:21:16 |
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
object Main { | |
implicit object Foo { | |
def (i: Int) eyes: String = "x" * i | |
} | |
trait Bar { | |
def (i: Int) nose: String | |
} | |
object Bar { | |
implicit def bar: Bar = new { | |
def (i: Int) nose: String = "y" * i | |
} | |
} | |
trait Baz { | |
def (i: Int) maj: String | |
} | |
implicit def baz: Baz = new { | |
def (i: Int) maj: String = "m" * i | |
} | |
def main(args: Array[String]): Unit = { | |
println("Hello world!") | |
implicitly[Foo.type] | |
implicitly[Bar] | |
implicitly[Baz] | |
println(202.eyes) | |
println(432.nose) | |
println(230.maj) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment