Created
May 6, 2014 20:05
-
-
Save orangy/a67d0e21390a21838dc4 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 Injected<T> { | |
fun instance() : T | |
} | |
trait Imap { | |
class object : Injected<Imap> { | |
override fun instance(): Imap { | |
return ImapImpl() | |
} | |
} | |
fun auth() {} | |
} | |
class ImapImpl : Imap {} | |
fun routeHandler<T, TC : Injected<T>>(t : TC, body : (T)->Unit) { | |
body(t.instance()) | |
} | |
val x = routeHandler(Imap) { imap -> | |
imap.auth() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment