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
I have a class with a companion object that extends KLogging(). I expect that the logger name would contain just the enclosing class name without the companion object class name. Even when a companion object is private.
This works fine when compiling it with kotlin 1.3 and below. This doesn't work with 1.4+.
Consider an example:
class PublicCompanion {
public companion object : KLogging()
val loggerName = logger.name
}
class PrivateCompanion {
private companion object : KLogging()
val loggerName = logger.name
}
fun main() {
println(PublicCompanion().loggerName)
println(PrivateCompanion().loggerName)
}
I have a class with a companion object that extends
KLogging()
. I expect that thelogger
name would contain just the enclosing class name without the companion object class name. Even when a companion object is private.This works fine when compiling it with kotlin 1.3 and below. This doesn't work with 1.4+.
Consider an example:
When compiling with kotlin 1.3 it outputs:
While with 1.4 it changes to:
There was a change in what visibility modifiers are put into bytecode by the kotlin compiler:
https://kotlinlang.org/docs/compatibility-guide-14.html#the-instance-field-of-a-companion-object-more-visible-than-the-companion-object-class-itself
As a reslut a reflection method that is used by
unwrapCompanionClass
started failing on private companions.So that it doesn't unwrap companion class name when it's private any more.
The text was updated successfully, but these errors were encountered: