https://kotlinlang.org logo
#getting-started
Title
# getting-started
l

Loney Chou

02/25/2023, 11:37 AM
Hello, may I ask the reason why referring to a function which is both member and extension is prohibited? On JVM all the top level functions are compiled into the same class, so they're all members effectively, but these top level extensions are referable. 🤔
c

CLOVIS

02/25/2023, 3:14 PM
Can you give a short example of what you're trying to do and doesn't work? Preferably using the playground: https://play.kotlinlang.org
l

Loney Chou

02/25/2023, 3:16 PM
No, I'm just curious.
Copy code
class A {
    fun A.a() {
        ::a // Error
    }
}
c

CLOVIS

02/25/2023, 3:27 PM
That's interesting 🤔 I have no idea
e

ephemient

02/25/2023, 6:48 PM
that needs both
this@A
and
this@a
receivers
c

CLOVIS

02/25/2023, 6:49 PM
Oh I see! It's because they could be different objects, so it's ambiguous which one's the reference would give