Hi! I have a question: why <KSNameImpl> doesn't ov...
# ksp
a
Hi! I have a question: why KSNameImpl doesn't override equals method? Wouldn't it be easier to write this
it.simpleName == shortName
instead of this
it.simpleName.asString() == shortName.asString()
. Before looking into the impl, I even thought that calling
asString()
is not efficient, because conversion from some inner representation to String might happen.
y
so even
===
would work
a
it is good, but i can't rely on this behaviour, as it can change (
thanks!
t
Yep, currently the equivalence is done through the cache. If we moved away from that implementation, we'll implement equals if needed.
👍 1
y
i think we should implement equals no? wouldn't that help if someone else implements KSName in their processor. Idk why people would do that but we have a couple of places in room where we implement those interfaces
t
That's a good point. Honestly there are some other places expecting specific implementation like KSTypeImpl. We didn't take the interaction with user implementation into consideration.
On the other hand, that use case is probably quite rare while making the implementation more complicated and less efficient in general. Unless there is a real example, I'm leaning against the complexity for the hypothetical cases.
y
yea i don't mean KSp should accept user implemented interfaces. But i don't think implementing equals adds any complexity to KSP
t
No, it doesn't add complexity in this case. If users need it, I'm happy to implement it.
a
It would also be nice if in KDocs of KSName was stated, that users can rely on calling equals, as it is implemented and guaranteed to work properly
t
Sure, will update the doc.