A compilation error is produced if one tries to serialize a class that has an Object[] array member:
J:\sdk\orange\dsss_imports\orange\serialization\Serializer.di(1592): Error: tuple index 0 exceeds 0
J:\sdk\orange\dsss_imports\orange\serialization\Serializer.di(1598): Error: template orange.serialization.Serializer.Serializer.objectStructSerializeHelper does not match any function template declaration.
One well known type that has an Object[] array is the java.util.Vector type in dwt2. I suspect it may happen with other arrays that have an element which is any class type.
Here is a minimal example to reproduce the issue:
import orange.serialization._;
import orange.serialization.archives._;
class Bar {
int a;
Object[] myArray;
}
void testObjectArray() {
Bar bar = new Bar();
bar.a = 3;
XmlArchive!char archive = new XmlArchive!(char);
Serializer serializer = new Serializer(archive);
serializer.serialize(bar); //<-- compilation fails here,
//because Serializer.serializeBaseTypes() gets called with a
//const(Object), which escapes the !is(T == Object)
//test done at objectStructSerializeHelper().
Bar b = serializer.deserialize!(Bar)(archive.untypedData);
assert(b.a == bar.a);
}
void main() {
testObjectArray();
}
What happens is that Serializer.serializeBaseTypes() shouldn't be called with T == const(Object). The caller, Serializer.objectStructSerializeHelper() doesn't check for const(Object). A fix could add Unqual!() to the check, changing:
A compilation error is produced if one tries to serialize a class that has an Object[] array member:
One well known type that has an Object[] array is the java.util.Vector type in dwt2. I suspect it may happen with other arrays that have an element which is any class type. Here is a minimal example to reproduce the issue:
What happens is that Serializer.serializeBaseTypes() shouldn't be called with T == const(Object). The caller, Serializer.objectStructSerializeHelper() doesn't check for const(Object). A fix could add Unqual!() to the check, changing:
to:
in the following functions:
Tested with D 2.062.