https://kotlinlang.org logo
Title
j

jw

03/13/2019, 3:05 AM
how do you make a property reference with that?
👆 2
s

sitepodmatt

03/13/2019, 3:06 AM
okay this is starting to sound familiar (although Im not sure I understood the answer in the early days)... can you elaborate
j

jw

03/13/2019, 3:06 AM
is
foo.bar
a bound reference to the property
Foo.bar
on instance
foo
or an invocation of the getter of the
bar
property on the
foo
instance? The syntax is ambiguous.
g

gildor

03/13/2019, 3:07 AM
class Foo {
    val bar: String = ""
    fun bar() = ""
}

Foo().bar // ???
Of course in theory it was possible to restrict such naming, but it would bring a lot of problems with JVM interop
s

sitepodmatt

03/13/2019, 3:11 AM
great thanks. that makes sense and that answers that question! cheers guys
next, why isn't this caught at compile time?
g

gildor

03/13/2019, 3:12 AM
caught at compile time?
s

sitepodmatt

03/13/2019, 3:13 AM
ah nevermind
::fn will fallback to use the property if there is no fun fn
g

gildor

03/13/2019, 3:15 AM
Yes, reference to properties are also supported
but resolution may be ambiguous
s

sitepodmatt

03/13/2019, 3:17 AM
thanks, til ☝️ everything above 🙂
g

gildor

03/13/2019, 3:19 AM
For example you can do even this (but only if you don’t have ambiguous naming, like in my first sample): https://pl.kotl.in/ryapLxLPN
👍 1