Kroppeb
02/05/2020, 10:39 AMoctylFractal
02/05/2020, 10:43 AMrun
define either invoke
or an actual function like fun Context<Int>.xyz(block: YourScope.() -> Unit)
. Then define YourScope
with the appropriate extension function.Kroppeb
02/05/2020, 10:47 AMStephan Schroeder
02/05/2020, 11:55 AMtest
?
In that case this works:
fun main() {
val foo: String = ""
Context<Int>(21).run{
test(foo) // should compile
}
Context<String>("test").run{
test(foo) // shouldn't compile
}
}
class Context<T>(value: T) {
}
fun Context<Int>.test(value: String) {
//
}