Hello, I'm looking for an extension that enables m...
# compiler
a
Hello, I'm looking for an extension that enables me to remove functions of a class or make it impossible to reference them, I've been able to do that with the SyntheticResolveExtension from the old compiler api but I'm looking for something K2 compatible.
d
It's not possible
y
You might instead want to use
Deprecated(DeprecationLevel.ERROR)
or
HIDDEN
on the declarations themselves. I don't think there's a way to add annotations in a compiler plugin though, so you'd have to do this manually
a
So there's no alternative to
SyntheticResolveExtension#generateSyntheticMethods
? are there any plans to add it in the future?
d
Actually
SyntheticResolveExtension
was introduced to provide a way to generate new declarations, not to remove existing So I'm curious how did you managed to do it
are there any plans to add it in the future?
No such plans But you can create a ticket with a description of your usecase
e
Wasn't there a compiler plugin to remove the copy function from data classes? https://github.com/AhmedMourad0/no-copy
๐Ÿ˜‚ 1
Ah literally it's you LMAO
๐Ÿ˜‚ 1
Didn't even notice!
Related to what the plugin did, at the time I was finding it very useful.
๐Ÿ™Œ 1
d
Thanks for the link Exposing resulting set of declarations to plugins is not the best API solution from our side @Ahmed Mourad this usecase with
copy
method actually is a known design problem, and we a looking to options to fix it on the language level Closest related ticket: KT-29675
a
@Edoardo Luppi Oh wow, never felt famous before ๐Ÿ˜‚๐Ÿ˜‚
๐Ÿ˜‚ 1
@dmitriy.novozhilov I see what you mean yeah, I'll open a ticket requesting a proper api for it. I'm aware of the open ticket yeah, I think it's not a priority of the Kotlin team atm, is it? given the K2 release and the features in the roadmap.
d
It definitely won't be included in 2.0, but we potentially can consider it in 2.1 timeframe
๐Ÿ™Œ 1
a
That would be amazing ๐Ÿ™Œ
a
Maybe a dumb question. But the invariants of the data class can be resolved in the init block of the data class right? However, that makes it a side effect instead of an Either you could return.
a
@Arjan van Wieringen That's one of the reasons yeah, another is that the
copy
method now throws exceptions as well which's a bit unorthodox. I actually wrote an article on the matter and that was one of the cases discussed: https://medium.com/swlh/value-based-classes-and-error-handling-in-kotlin-3f14727c0565