TornadoFX Version: 1.5.1
Kotlin Version: 1.0.3
Define a class with an inherited property:
open class Person {
var name = property("")
fun nameProperty() = getProperty(Person::name)
}
class Student : Person()
and try to access the property:
Student().nameProperty()
Expected:
A StringProperty is returned.
Actual:
An exception is thrown:
java.lang.NoSuchFieldException: name$delegate
at java.lang.Class.getDeclaredField(Class.java:2070)
at tornadofx.PropertiesKt.getProperty(Properties.kt:24)
...
Culprit:
Properties.kt:24
val field = this.javaClass.getDeclaredField("${prop.name}\$delegate")
getDeclaredField only returns the fields directly declared in the class and cannot find fields of a parent class.
Thanks for reporting this :) You are correct, there was no recursive support in the getProperty function. I have added it now, can you verify that it works for you?
Please note that your example had a typo so even with the fix you would get an error with this code:
var name = property("")
You must use the property delegate call, but I suspect you already know this and just had a typo in the example :)
var name by property("")
A response AND fix within 20 minutes of reporting the issue: I am seriously impressed right now. Thank you so much! This project is amazing :)
(You are of course right, I messed up the property declaration in the example.)
You never get used to how fast @edvin works :smile:
My pleasure @lukas-eibensteiner :) Thanks again for reporting this!
Most helpful comment
You never get used to how fast @edvin works :smile: