Gat Tag
04/19/2024, 1:24 PMinterface MyThing<A: Any, B: MyRoot?> { }
extension <A: Any, B: MyRoot?> (MyThing<A, B>){
val thingA: A get() = TODO()
val thingB: Optional<B & Any> get() = TODO()
val otherThing: (A) -> String by TODO()
fun <C: SomeType> doThing(): Pair<A, C> {
return TODO()
}
}
A reduction step would emit:
interface MyThing<A: Any, B: MyRoot?> { }
val <A: Any, B: MyRoot?> MyThing<A, B>.thingA: A get() = TODO()
val <A: Any, B: MyRoot?> MyThing<A, B>.thingB: Optional<B & Any> get() = TODO()
val <A: Any, B: MyRoot?> MyThing<A, B>.otherThing: (A) -> String by TODO()
fun <A: Any, B: MyRoot?, C: SomeType> MyThing<A, B>.doThing(): Pair<A, C> {
return TODO()
}
This syntax could also be used inside a class like declaration for member extension functions as well.
I could also see more widely applicable usage when allowing something similar for the upcoming context receivers allowing a block for which all declarations require the specified contexts.Loney Chou
04/21/2024, 6:00 PMgroostav
04/25/2024, 12:47 AMcontext
to include your proposal.
having sent some time with dotnet I also liked using this
as a keyword in a signature, so i propose something like:
interface MyThing<A: Any, B: MyRoot?> { }
context<A: Any, B: MyRoot>(this: MyThing<A, B>) {
val thingA: A get() = TODO()
//...
}
Gat Tag
04/25/2024, 6:13 AMcontext
blocks should also be a thing but I think they should just stick to declaring context parameters and not providing a mechanism for extension receivers. I also recognize that neither of my reasons are very rigorous and am open to changing my opinionGat Tag
04/29/2024, 2:50 AMGat Tag
04/29/2024, 2:51 AMLoney Chou
05/02/2024, 4:46 PM