Open maxim092001 opened 1 year ago
I really like this. Are there any corresponding YouTrack issues or other conversations that we can link to?
Cool to have this, reduce a lots of boilerplates
I would replace the annotation with a modifier. Gate-locking a language feature behind an annotation isn't a common Kotlin thing to do - annotations are usually used for metadata (e.g., @PublishedApi
).
class A<this Self>
class B<this Self, T>
class C<T, this Self>
class D<out this Self>
That way, you reduce the confusion from the explicit-self-generic syntax (the C<Int, C<Int, *>>
instead of C<Int>
part), remove the need for an annotation (therefore increasing readability and beginner-approachability), and allows using whatever name (and order) you want for the generic instead of forcing it by language.
The modifier's name could also be self
, current
or dynamic
.
PR