How to provide one’s own class to a typed instance?

Example of what I want to do (this yields an error):

class Foo() { companion object { private val log = Logger<this::class>() } } 

Normally you use the logger like this:

class Foo() { companion object { private val log = Logger<Foo>() } } 

Is there a way to do this? My use case for this is that I make copies of the same class to write a version 2.0 of the class. E.g:

class Foo2() { companion object { private val log = Logger<Foo2>() } } 

It’s really annoying for me to have to update the Logger<TypeName> as well so I’d prefer if it just inferred the type from the current class.

submitted by /u/IllTryToReadComments
[link] [comments]