From b313a13caf63a5da0c16a1d584c95ea070df1aed Mon Sep 17 00:00:00 2001 From: Mingun Date: Fri, 27 Nov 2020 23:13:31 +0500 Subject: [PATCH] Unify processing of array types in TypeDetector Both ArrayTypeInStream and CalcArrayType the only existing successors of the sealed class TypeDetector so we can do that simplification --- .../io/kaitai/struct/translators/TypeDetector.scala | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) 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 6914a3dca..c06a6867c 100644 --- a/shared/src/main/scala/io/kaitai/struct/translators/TypeDetector.scala +++ b/shared/src/main/scala/io/kaitai/struct/translators/TypeDetector.scala @@ -101,14 +101,9 @@ class TypeDetector(provider: TypeProvider) { } case Ast.expr.Subscript(container: Ast.expr, idx: Ast.expr) => (detectType(container) match { - case ArrayTypeInStream(elType: DataType) => + case arr: ArrayType => detectType(idx) match { - case _: IntType => elType - case idxType => throw new TypeMismatchError(s"unable to index an array using $idxType") - } - case CalcArrayType(elType: DataType) => - detectType(idx) match { - case _: IntType => elType + case _: IntType => arr.elType case idxType => throw new TypeMismatchError(s"unable to index an array using $idxType") } case _: BytesType => Int1Type(false)