Hello. I'm not able to reference a method of the c...
# announcements
m
Hello. I'm not able to reference a method of the companion object of a sealed class as
MySealedClass::method
. I have to write explicitly
MySealedClass.Companion::method
. Is this normal?
👌 1
c
Method references (
::
) work differently than calling a method. There is no instance of that class that can be used to help determine it, so the compiler can’t know if
MySealedClass::method
refers to
fun method()
in
MySealedClass
or its
Companion
. You could even have the same function in both, so there needs to be a way to resolve the ambiguity
💯 2
m
Thanks, @Casey Brooks! I didn't think of that problem.