An example with `::` (bound callable reference?). ...
# announcements
g
An example with
::
(bound callable reference?). Any way to properly import
Companion
so I don't see it in the code?
Copy code
class Foo(bar: () -> Bar)

class Bar {
    companion object {
        fun newInstance() = Bar()
    }
}
....
Foo(Bar.Companion::newInstance) //<--- works
Foo(Bar::newInstance) //<--- doesn't work
r
No, as those have different meaning.
Bar::newInstance
is a reference to a function on
Bar
.
You could do this (though it feels a bit of a hack and changes the semantics considerably):
Copy code
class Bar {
    companion object : () -> Bar {
        override fun invoke() = Bar()
    }
}

Foo(Bar)
🙏 1
g
probably won't use it but I'm glad I've seen it)