Open insomniacslk opened 2 years ago
I just realized that the compiler cannot infer the right type, because parent
could be more than one type (that is, either Exif_ExifBody
or Exif_ExifBody_Ifd
), so interface{}
is the most appropriate here, then it requires runtime type casting to read _is_le
properly
Another (ugly) option is to use reflection. If the type is unknown, the attribute can be resolved at runtime like this:
// Using reflection to read this._parent._is_le, because this._parent could
// be one of Exif_ExifBody or Exif_ExifBody_Ifd .
// Elem() is called two more times, first to resolve the interface, and then to resolve the pointer.
this._is_le = int(reflect.ValueOf(&this._parent).Elem().Elem().Elem().FieldByName("_is_le").Int())
but I hope there's a better option
Hi, I noticed that
image/exif.ksy
is broken for Go, the generated files yield the following errors:The type of
Exif_ExifBody_Ifd._parent
isinterface{}
, hence the instructionthis._is_le = this._parent._is_le
fails because it is generated asAnyType
instead of being converted toExif_ExifBody_Ifd
.This happens with both Go 1.17 and Go 1.18.
The issue can be reproduced with the following commands:
I don't have experience with Scala, or I'd have submitted a PR, let me know if I should provide more information.
Thanks!