Last active
July 13, 2017 07:43
-
-
Save bergmark/de959929c8ad10a7369ba0eafe629417 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
| trait AbstractResource[T] { | |
| val version: String | |
| type Foo | |
| implicit def self: this.type = this | |
| } | |
| object MyResource extends AbstractResource[MyResource] { | |
| override final val version = "v3" | |
| override type Foo = Int | |
| } | |
| class MyResource | |
| object Foo { | |
| def printVersion[T]()(implicit resource: AbstractResource[T]): Unit = | |
| println(resource.version) | |
| printVersion[MyResource]() | |
| def printFoo[T](implicit resource: AbstractResource[T]): (resource.Foo) => Unit = | |
| (foo: resource.Foo) => println(foo) | |
| val printInt: (Int) => Unit = printFoo[MyResource] | |
| printInt(1) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment