You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, this will work at runtime, since the fallback to retrieve the serializer through the $serializer class will be used instead.
To Reproduce
@Serializable
class HasPrivateCompanion( val output: String )
{
private companion object
}
Expected behavior
Not really certain. I suppose the main reason for attempting to look up the serializer through the Companion object is to speed up this process, assuming that it is significantly slower than retrieving it through $serializer. I presume lookup through Companion would still be preferred even if it is private. This should be fairly straightforward with isAccessible.
Alternatively, it does seem like more code can be obfuscated if the serializer is retrieved through it's companion object. It is by updating the ProGuard rules that I found out about this. This would thus be another reason to make sure private companions be accessed, otherwise a custom rule for the class with the private companion needs to be added.
Environment
Kotlin version: 1.4.31
Library version: 1.1.0
Kotlin platforms: JVM
Gradle version: 7.0.2
The text was updated successfully, but these errors were encountered:
Describe the bug
Not really a bug, just an observation based on looking at the codebase. I can do a PR later if relevant.
Companion objects are retrieved through the "Companion" object (unless it is a named companion object), but this will fail in case the companion object isn't public.
isAccessible
isn't set to true.However, this will work at runtime, since the fallback to retrieve the serializer through the
$serializer
class will be used instead.To Reproduce
Expected behavior
Not really certain. I suppose the main reason for attempting to look up the serializer through the
Companion
object is to speed up this process, assuming that it is significantly slower than retrieving it through$serializer
. I presume lookup throughCompanion
would still be preferred even if it is private. This should be fairly straightforward withisAccessible
.Alternatively, it does seem like more code can be obfuscated if the serializer is retrieved through it's companion object. It is by updating the ProGuard rules that I found out about this. This would thus be another reason to make sure private companions be accessed, otherwise a custom rule for the class with the private companion needs to be added.
Environment
The text was updated successfully, but these errors were encountered: