in kotlin 1.4.10, it is inferred as `ObjectPropert...
# tornadofx
m
in kotlin 1.4.10, it is inferred as
ObjectProperty<Double>
which throws
Copy code
java.lang.ClassCastException: class tornadofx.BindingAwareSimpleDoubleProperty cannot be cast to class javafx.beans.property.ObjectProperty
b
I think this is more of a problem with the Kotlin compiler, is the new IR included?
m
the new inference algorithm? yes
b
I think the problem is in it, try turning it off
m
I worked around by casting to Property<Double>
looking at the code, it seems the new inference is correct
well, maybe the inference on the bind it the root of the problem
b
Copy code
errorMaxSpeedProperty
what type?
m
in Limits class, errorMaxSpeedProperty() returns a casted ObjectProperty<Double>
from Any.getProperty()
but Any.getProperty() is actually accessing the Property<Double> in Limits::errorMaxSpeed
so looks like the old inference would use that type but the new one honors the type cast from Any.getProperty() ?
b
what type of property do you have? What it outputs I understood, but this is more likely an error, since the tornada has declared <reified N: Any, ReturnType: Property <N>>
m
it's in the code I posted
Copy code
class Limits {
    var errorMaxSpeed: Double by property(0.0)
    fun errorMaxSpeedProperty() = getProperty(Limits::errorMaxSpeed)
}
b
also turn off new type inference, and check for caste
m
I know it works with the old
since it was working fine until I updated recently
looking at the changes to 1.4 it may have to do with inference for delegated properties
b
so I wrote that this is a problem of the new type inference. Write to yutrek, let's see what they say
m
right, tornadofx is returning ObjectProperty<Double> when using
getProperty(Limits::errorMaxSpeed)
b
Type inference failed: inline fun <reified S : T, reified T : Any> TextInputControl.bind ( property: ObservableValue<S>, readonly: Boolean = ..., converter: StringConverter<T>? = ..., format: Format? = ... ) : Unit cannot be applied to receiver: TextField
m
and the new inference is doing
bind<Double,ObjectProperty<Double>,ObjectProperty<Double>>(Limits::errorMaxSpeed)
which matches what getProperty() returns
the old inference I think was inferring
bind<Double, Property<Double>, Property<Double>>(Limits::errorMaxSpeed)
which is why it worked
I'm not getting any errors on the textfield bind
b
which implement from
Property <Double>
m
ah, I see, ObjectProperty<T> implements Property<T>
b
It seems to me that you did not give the complete code.
Copy code
val limits = Limits () ?
val model = LimitsViewModel (limits) ?
but not stop, I didn’t see it
m
well, that code is a simplification of my code
b
I'm a little blunt, sorry
m
yeah I've followed all the tornadofx code and how it creates the BindingAwareSimpleDoubleProperty
makes my head spin trying to follow it all
b
my code does not compile even on 1.3.72
m
let me create a working example
b
I myself met with this problem, dropped the screen above, and I did a manual cast. Start Issue on github, I'll try to look at the weekend. Also write the tornadofx version
vendor and JVM version
m
it should be
Copy code
bind(model.errorMaxSpeed)
dot not colon colon
I'll create the issue
b
yes exactly, it should be through the point. although the error is still strange
I'll create the issue
I don’t see, but can I link?
m
I haven't created it yet
if you use the alternate syntax
Copy code
class LimitsTest {
    val errorMaxSpeedProperty = SimpleDoubleProperty(0.0)
    var errorMaxSpeed by errorMaxSpeedProperty
}
The new inference in 1.4 uses "SimpleDoubleProperty" while the 1.3 uses "Property<Number!>"
b
Well, this is already an error of new type inference. Ask the Kotlin developers if it was a bug before or it has appeared now.
more precisely why this function is chosen