diff --git a/js/src/main/scala/io/kaitai/struct/format/JavaScriptKSYParser.scala b/js/src/main/scala/io/kaitai/struct/format/JavaScriptKSYParser.scala index 4aafd4e4d..dbb48451b 100644 --- a/js/src/main/scala/io/kaitai/struct/format/JavaScriptKSYParser.scala +++ b/js/src/main/scala/io/kaitai/struct/format/JavaScriptKSYParser.scala @@ -22,7 +22,7 @@ object JavaScriptKSYParser { def yamlJavascriptToScala(src: Any): Any = { src match { - case array: js.Array[AnyRef] => + case array: js.Array[_] => array.toList.map(yamlJavascriptToScala) case _: String | _: Int | _: Double | _: Boolean => src diff --git a/jvm/src/main/scala/io/kaitai/struct/formats/JavaKSYParser.scala b/jvm/src/main/scala/io/kaitai/struct/formats/JavaKSYParser.scala index 8415877f2..6e38c09b8 100644 --- a/jvm/src/main/scala/io/kaitai/struct/formats/JavaKSYParser.scala +++ b/jvm/src/main/scala/io/kaitai/struct/formats/JavaKSYParser.scala @@ -73,9 +73,9 @@ object JavaKSYParser { def yamlJavaToScala(src: Any): Any = { src match { - case jlist: JList[AnyRef] => + case jlist: JList[_] => jlist.toList.map(yamlJavaToScala) - case jmap: JMap[String, AnyRef] => + case jmap: JMap[_, _] => jmap.toMap.mapValues(yamlJavaToScala) case _: String => src diff --git a/shared/src/main/scala/io/kaitai/struct/JSON.scala b/shared/src/main/scala/io/kaitai/struct/JSON.scala index adb3fc04c..4ffda0fa8 100644 --- a/shared/src/main/scala/io/kaitai/struct/JSON.scala +++ b/shared/src/main/scala/io/kaitai/struct/JSON.scala @@ -23,7 +23,7 @@ object JSON extends CommonLiterals { case v: Int => v.toString case v: String => stringToJson(v) case v: List[_] => listToJson(v) - case v: Map[String, _] => mapToJson(v) + case v: Map[_, _] => mapToJson(v) } } @@ -33,9 +33,9 @@ object JSON extends CommonLiterals { def listToJson(obj: List[_]): String = "[" + obj.map((x) => stringify(x)).mkString(",") + "]" - def mapToJson(obj: Map[String, _]): String = { + def mapToJson(obj: Map[_, _]): String = { val kvs = obj.map { case (k, v) => - stringToJson(k) + ": " + stringify(v) + stringToJson(k.toString) + ": " + stringify(v) } "{" + kvs.mkString(",") + "}" } diff --git a/shared/src/main/scala/io/kaitai/struct/datatype/Endianness.scala b/shared/src/main/scala/io/kaitai/struct/datatype/Endianness.scala index 4606d88e9..aa6f1cd24 100644 --- a/shared/src/main/scala/io/kaitai/struct/datatype/Endianness.scala +++ b/shared/src/main/scala/io/kaitai/struct/datatype/Endianness.scala @@ -26,7 +26,7 @@ object Endianness { case None => None case Some("be") => Some(BigEndian) case Some("le") => Some(LittleEndian) - case Some(srcMap: Map[Any, Any]) => + case Some(srcMap: Map[_, _]) => val endianMap = ParseUtils.asMapStr(srcMap, path) Some(fromMap(endianMap, path)) case _ => diff --git a/shared/src/main/scala/io/kaitai/struct/format/AttrSpec.scala b/shared/src/main/scala/io/kaitai/struct/format/AttrSpec.scala index 6f3180c6d..cd15d55c0 100644 --- a/shared/src/main/scala/io/kaitai/struct/format/AttrSpec.scala +++ b/shared/src/main/scala/io/kaitai/struct/format/AttrSpec.scala @@ -220,7 +220,7 @@ object AttrSpec { DataType.fromYaml( Some(simpleType), path, metaDef, yamlAttrArgs ) - case switchMap: Map[Any, Any] => + case switchMap: Map[_, _] => val switchMapStr = ParseUtils.anyMapToStrMap(switchMap, path) parseSwitch(switchMapStr, path, metaDef, yamlAttrArgs) case unknown => diff --git a/shared/src/main/scala/io/kaitai/struct/format/EnumValueSpec.scala b/shared/src/main/scala/io/kaitai/struct/format/EnumValueSpec.scala index 905e968a6..881f7b798 100644 --- a/shared/src/main/scala/io/kaitai/struct/format/EnumValueSpec.scala +++ b/shared/src/main/scala/io/kaitai/struct/format/EnumValueSpec.scala @@ -9,7 +9,7 @@ object EnumValueSpec { fromSimpleName(name, path) case x: Boolean => fromSimpleName(x.toString, path) - case srcMap: Map[Any, Any] => + case srcMap: Map[_, _] => fromMap(ParseUtils.anyMapToStrMap(srcMap, path), path) case _ => throw YAMLParseException.badType("string or map", src, path) diff --git a/shared/src/main/scala/io/kaitai/struct/format/ParseUtils.scala b/shared/src/main/scala/io/kaitai/struct/format/ParseUtils.scala index 430184c65..6fefe9143 100644 --- a/shared/src/main/scala/io/kaitai/struct/format/ParseUtils.scala +++ b/shared/src/main/scala/io/kaitai/struct/format/ParseUtils.scala @@ -126,12 +126,12 @@ object ParseUtils { ): List[T] = { val pathField = path ++ List(field) src.get(field) match { - case Some(srcList: List[Any]) => + case Some(srcList: List[_]) => srcList.zipWithIndex.map { case (element, idx) => convertFunc(element, pathField ++ List(idx.toString)) } - case Some(singleObject: T) => - List(singleObject) + case Some(singleObject) => + List(convertFunc(singleObject, pathField)) case None => List() case unknown => @@ -196,9 +196,9 @@ object ParseUtils { } } - def asMap(src: Any, path: List[String]): Map[Any, Any] = { + def asMap(src: Any, path: List[String]): Map[_, _] = { src match { - case srcMap: Map[Any, Any] => + case srcMap: Map[_, _] => srcMap case unknown => throw YAMLParseException.badType("map", unknown, path) @@ -211,14 +211,14 @@ object ParseUtils { def asMapStrStr(src: Any, path: List[String]): Map[String, String] = anyMapToStrStrMap(asMap(src, path), path) - def anyMapToStrMap(anyMap: Map[Any, Any], path: List[String]): Map[String, Any] = { + def anyMapToStrMap[V](anyMap: Map[_, V], path: List[String]): Map[String, V] = { anyMap.map { case (key, value) => val keyStr = asStr(key, path) keyStr -> value } } - def anyMapToStrStrMap(anyMap: Map[Any, Any], path: List[String]): Map[String, String] = { + def anyMapToStrStrMap(anyMap: Map[_, _], path: List[String]): Map[String, String] = { anyMap.map { case (key, value) => val keyStr = asStr(key, path) val valueStr = asStr(value, path ++ List(keyStr)) diff --git a/shared/src/main/scala/io/kaitai/struct/format/ValidationSpec.scala b/shared/src/main/scala/io/kaitai/struct/format/ValidationSpec.scala index cc3f11fc7..03672c3d8 100644 --- a/shared/src/main/scala/io/kaitai/struct/format/ValidationSpec.scala +++ b/shared/src/main/scala/io/kaitai/struct/format/ValidationSpec.scala @@ -85,7 +85,7 @@ object ValidationSpec { fromString(x.toString, path) case x: Long => fromString(x.toString, path) - case srcMap: Map[Any, Any] => + case srcMap: Map[_, _] => fromMap(ParseUtils.anyMapToStrMap(srcMap, path), path) case _ => throw YAMLParseException.badType("string or map", src, path)