natpryce
10/10/2018, 7:50 AMobject foo {
operator fun invoke() {
println("an object")
}
}
fun foo() {
println("a function")
}
fun main(args: Array<String>) {
foo() // prints "a function"
}
louiscad
10/10/2018, 8:09 AMchristophsturm
10/10/2018, 9:39 AMlouiscad
10/10/2018, 9:43 AMfoo.invoke()
if needed.natpryce
10/10/2018, 9:43 AMnatpryce
10/10/2018, 9:44 AMnatpryce
10/10/2018, 9:44 AMgildor
10/10/2018, 9:44 AMlouiscad
10/10/2018, 9:44 AMfoo
😜natpryce
10/10/2018, 9:45 AMnatpryce
10/10/2018, 9:45 AMnatpryce
10/10/2018, 9:45 AMgildor
10/10/2018, 9:45 AMnatpryce
10/10/2018, 9:46 AMgildor
10/10/2018, 9:46 AMlouiscad
10/10/2018, 9:46 AMnatpryce
10/10/2018, 9:46 AMnatpryce
10/10/2018, 9:47 AMnatpryce
10/10/2018, 9:48 AMlouiscad
10/10/2018, 9:50 AMspand
10/10/2018, 10:03 AMnatpryce
10/10/2018, 10:06 AMelizarov
10/10/2018, 10:50 AMobject foo
is in another file? In another package (and imported)? Inherited from parent class? Auto-imported from kotlin stdlib? When exactly it should be a warning?natpryce
10/10/2018, 10:51 AMnatpryce
10/10/2018, 10:51 AMelizarov
10/10/2018, 10:52 AMnatpryce
10/10/2018, 10:52 AMnatpryce
10/10/2018, 10:52 AMnatpryce
10/10/2018, 10:53 AMelizarov
10/10/2018, 10:53 AMfoo
or an declaration of foo? Or on declaration of foo.invoke
(given that foo()
function is present)?natpryce
10/10/2018, 10:54 AMnatpryce
10/10/2018, 10:54 AMnatpryce
10/10/2018, 10:54 AMobject foo
and fun foo
assumes two namespaces and is therefore not portable.elizarov
10/10/2018, 10:55 AMfoo
is not ambiguous. Kotlin perfectly distinguishes between types and functions (see List
interface and List()
function in stdlib).natpryce
10/10/2018, 10:55 AMelizarov
10/10/2018, 10:56 AMinvoke
operator. Even then, it is unambiguously resolved to a function both by compiler and IDE (you can Ctrl+Click on foo()
call to confirm that)natpryce
10/10/2018, 10:56 AMfoo
I’m concerned about, it’s the value named foo
elizarov
10/10/2018, 10:57 AMnatpryce
10/10/2018, 10:58 AMfoo()
refers to two different things in the same namespace.natpryce
10/10/2018, 10:58 AMelizarov
10/10/2018, 11:00 AMfoo
(short name needs to be always resolved using some rules, because those names are short and would otherwise conflict in any large project)natpryce
10/10/2018, 11:02 AMpniederw
10/10/2018, 9:59 PMnatpryce
10/10/2018, 10:05 PMelizarov
10/10/2018, 10:09 PMelizarov
10/10/2018, 10:10 PMnatpryce
10/11/2018, 1:42 PMpniederw
10/11/2018, 6:19 PMelizarov
10/11/2018, 6:22 PMelizarov
10/11/2018, 6:24 PMnatpryce
10/11/2018, 11:43 PMnatpryce
10/11/2018, 11:43 PMDico
10/12/2018, 4:54 AMelizarov
10/12/2018, 7:42 AMelizarov
10/12/2018, 7:43 AMbashor
10/15/2018, 1:20 PMKT-27490JFTR: Compilation error when compile to JS is the right(expected) behavior, at least for current BE. The reason is that the compiler has to generate the same name for declarations object foo and fun foo but it’s impossible on JS. Note it wouldn’t be compilation error if the function had parameters since its name would be mangled (got additional prefix). In the case, you want to left such names in Kotlin code you can use JsName to resolve the issue.