#Smart cast 'Loop' is impossible, because 'loop' is a property that has open or custom getter (kotlin

3 messages · Page 1 of 1 (latest)

ember vigil
#
abstract class Envelope {

    abstract val propertyType: PropertyType
    abstract val envelopeExpression: String
    abstract val loop: Loop?

    /**
     * Returns the envelope's value for a certain frame t.
     * @param t The frame index. If loop is not set to null, the loop index will be calculated and used instead of t.
     */
    fun getValueAt(t: Int): Double {
        var index = t
        if (loop != null)
            index = 5 % loop.duration

        return ExpressionBuilder(envelopeExpression)
            .variables("t")
            .build()
            .setVariable("t", index.toDouble()).evaluate()
    }
}

Why does this error appear? How do I fix it?

wheat fractalBOT
#

This post has been reserved for your question.

Hey @ember vigil! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.