Slackbot
04/14/2022, 6:04 PMYoussef Shoaib [MOD]
04/14/2022, 6:21 PMScope has:
fun <S: Gen.A, P: Gen.B> Scope<S, P>.scopeId() = this
(this is really useful when debugging weird context receivers issues since you can't quite see a list of context receivers rn)
and hitting Ctrl-Shift-P in IDEA says that the Scope is of type Scope<MyGen.A, out Any?> which is really weirdYoussef Shoaib [MOD]
04/14/2022, 6:24 PMoperator fun <A : Gen.A, B : Gen.B> Gen<A, B>.invoke(
rules: context(Scope<A, B>) A.(TypeWrapper<B>) -> Unit
) {
with(Scope(this)) {
rules(this, a(), TypeWrapper.IMPL)
}
}
fun main() {
MyGen {
a {
scopeId()
// `this` now shows `MyGen.B`
println(b) // Error: Unresolved reference: b
}
}
}
fun <S: Gen.A, P: Gen.B> Scope<S, P>.scopeId() = thisYoussef Shoaib [MOD]
04/14/2022, 6:25 PMYoussef Shoaib [MOD]
04/14/2022, 6:27 PMYoussef Shoaib [MOD]
04/14/2022, 9:09 PMtype()). In the same thread, I provided this list of TypeWrappers up to 22 type params.