From 15959f0ea49175e245469f493598695ef1e8cd65 Mon Sep 17 00:00:00 2001 From: Mikhail Yakshin Date: Tue, 26 Mar 2024 14:57:05 +0000 Subject: [PATCH] CommonMethods + TypeDetector: handle `._io` call on generic KaitaiStruct objects properly --- .../main/scala/io/kaitai/struct/translators/CommonMethods.scala | 2 +- .../main/scala/io/kaitai/struct/translators/TypeDetector.scala | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/shared/src/main/scala/io/kaitai/struct/translators/CommonMethods.scala b/shared/src/main/scala/io/kaitai/struct/translators/CommonMethods.scala index f998fb186..6b177d35e 100644 --- a/shared/src/main/scala/io/kaitai/struct/translators/CommonMethods.scala +++ b/shared/src/main/scala/io/kaitai/struct/translators/CommonMethods.scala @@ -166,7 +166,7 @@ abstract trait CommonMethods[T] extends TypeDetector { valType match { case KaitaiStructType | CalcKaitaiStructType(_) => attr.name match { - case Identifier.PARENT => kaitaiStructField(value, attr.name) + case Identifier.PARENT | Identifier.IO => kaitaiStructField(value, attr.name) } case ut: UserType => userTypeField(ut, value, attr.name) diff --git a/shared/src/main/scala/io/kaitai/struct/translators/TypeDetector.scala b/shared/src/main/scala/io/kaitai/struct/translators/TypeDetector.scala index 27a0c0243..fefea16fa 100644 --- a/shared/src/main/scala/io/kaitai/struct/translators/TypeDetector.scala +++ b/shared/src/main/scala/io/kaitai/struct/translators/TypeDetector.scala @@ -160,6 +160,7 @@ class TypeDetector(provider: TypeProvider) { case KaitaiStructType | CalcKaitaiStructType(_) => attr.name match { case Identifier.PARENT => CalcKaitaiStructType() + case Identifier.IO => KaitaiStreamType case _ => throw new MethodNotFoundError(attr.name, valType) } case t: UserType =>