I have the following declarations in Xcore:
class ValueBase { ... }
class ValueArray extends ValueBase
{
int size
double [] values
String valueUnit
op boolean isValueEqual(Value v)
{
if (!(v instanceof IValueArray))
{
return false
}
val other = v as IValueArray;
return Iterables.elementsEqual(this.values, other.values);
}
op boolean equals(Value v)
{
return super.equals(v) && isValueEqual(v) &&
(v instanceof IValueArray) &&
Objects.equals(valueUnit, (v as IValueArray).valueUnit)
}
}
ValueBase
implements its own equals()
method. In the concrete class ValueArray
, I want to call super.equals()
to compare the base class' common fields and then do comparisons specific to the concrete class.
But Xcore complains about that code that it "Couldn't resolve reference to JvmIdentifiableElement super
".
How can I call the equals()
-method from the super class?
I had to make some assumptions about the code that you don't show here, but the short answer is that it works. You're calling
super.equals
correctly. But as I said, I had to make some assumptions. So here is what I have that seems to be fine with Xcore.No complaints from Xcore. So am I missing something?