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 f2ca22629..bb739b82c 100644 --- a/js/src/main/scala/io/kaitai/struct/format/JavaScriptKSYParser.scala +++ b/js/src/main/scala/io/kaitai/struct/format/JavaScriptKSYParser.scala @@ -29,7 +29,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 1096dc1ef..986738b1c 100644 --- a/jvm/src/main/scala/io/kaitai/struct/formats/JavaKSYParser.scala +++ b/jvm/src/main/scala/io/kaitai/struct/formats/JavaKSYParser.scala @@ -82,9 +82,9 @@ object JavaKSYParser { def yamlJavaToScala(src: Any): Any = { src match { - case jlist: JList[AnyRef] => + case jlist: JList[_] => jlist.asScala.toList.map(yamlJavaToScala) - case jmap: JMap[String, AnyRef] => + case jmap: JMap[_, _] => jmap.asScala.toMap.view.mapValues(yamlJavaToScala).toMap 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 b86b3a25f..f465df365 100644 --- a/shared/src/main/scala/io/kaitai/struct/JSON.scala +++ b/shared/src/main/scala/io/kaitai/struct/JSON.scala @@ -24,7 +24,7 @@ object JSON extends CommonLiterals { case v: Int => v.toString case v: String => stringToJson(v) case v: collection.Seq[_] => seqToJson(v) - case v: Map[String, _] => mapToJson(v) + case v: Map[_, _] => mapToJson(v) } } @@ -37,9 +37,9 @@ object JSON extends CommonLiterals { def seqToJson(obj: collection.Seq[_]): String = "[" + obj.map((x) => stringify(x)).mkString(",") + "]" - def mapToJson(obj: Map[String, Any]): String = { + def mapToJson[K, V](obj: Map[K, V]): 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 592c13e07..3b363e158 100644 --- a/shared/src/main/scala/io/kaitai/struct/datatype/Endianness.scala +++ b/shared/src/main/scala/io/kaitai/struct/datatype/Endianness.scala @@ -27,7 +27,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 d9e595dca..d632d8027 100644 --- a/shared/src/main/scala/io/kaitai/struct/format/AttrSpec.scala +++ b/shared/src/main/scala/io/kaitai/struct/format/AttrSpec.scala @@ -219,7 +219,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 ++ List("type"), 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 6e17ac053..bb7dcfe3d 100644 --- a/shared/src/main/scala/io/kaitai/struct/format/EnumValueSpec.scala +++ b/shared/src/main/scala/io/kaitai/struct/format/EnumValueSpec.scala @@ -11,7 +11,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 KSYParseError.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 1481cddcb..6ffae9f5b 100644 --- a/shared/src/main/scala/io/kaitai/struct/format/ParseUtils.scala +++ b/shared/src/main/scala/io/kaitai/struct/format/ParseUtils.scala @@ -136,12 +136,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 => @@ -221,14 +221,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 3f404ce4f..ed1a04470 100644 --- a/shared/src/main/scala/io/kaitai/struct/format/ValidationSpec.scala +++ b/shared/src/main/scala/io/kaitai/struct/format/ValidationSpec.scala @@ -105,7 +105,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 KSYParseError.badType("string or map", src, path)