From 11c1318d56cb0da8ebad9a02b4305bfff99986aa Mon Sep 17 00:00:00 2001
From: Mingun <alexander_sergey@mail.ru>
Date: Wed, 17 Apr 2024 22:35:28 +0500
Subject: [PATCH] Remove unnecessary Option in filename for importAbsolute and
 importRelative

In all cases this methods called with Some(...)
---
 .../io/kaitai/struct/format/JavaScriptClassSpecs.scala    | 4 ++--
 .../scala/io/kaitai/struct/formats/JavaClassSpecs.scala   | 8 ++++----
 .../main/scala/io/kaitai/struct/format/ClassSpecs.scala   | 4 ++--
 .../scala/io/kaitai/struct/precompile/LoadImports.scala   | 2 +-
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/js/src/main/scala/io/kaitai/struct/format/JavaScriptClassSpecs.scala b/js/src/main/scala/io/kaitai/struct/format/JavaScriptClassSpecs.scala
index b95b988a6..62e0eee33 100644
--- a/js/src/main/scala/io/kaitai/struct/format/JavaScriptClassSpecs.scala
+++ b/js/src/main/scala/io/kaitai/struct/format/JavaScriptClassSpecs.scala
@@ -13,9 +13,9 @@ class JavaScriptClassSpecs(importer: JavaScriptImporter, firstSpec: ClassSpec)
   val MODE_REL = "rel"
   val MODE_ABS = "abs"
 
-  override def importRelative(name: String, path: List[String], inFile: Option[String]): Future[Option[ClassSpec]] =
+  override def importRelative(name: String, path: List[String], inFile: String): Future[Option[ClassSpec]] =
     doImport(name, path, MODE_REL)
-  override def importAbsolute(name: String, path: List[String], inFile: Option[String]): Future[Option[ClassSpec]] =
+  override def importAbsolute(name: String, path: List[String], inFile: String): Future[Option[ClassSpec]] =
     doImport(name, path, MODE_ABS)
 
   def doImport(name: String, path: List[String], mode: String): Future[Option[ClassSpec]] = {
diff --git a/jvm/src/main/scala/io/kaitai/struct/formats/JavaClassSpecs.scala b/jvm/src/main/scala/io/kaitai/struct/formats/JavaClassSpecs.scala
index d5df4554a..49d5cf4f6 100644
--- a/jvm/src/main/scala/io/kaitai/struct/formats/JavaClassSpecs.scala
+++ b/jvm/src/main/scala/io/kaitai/struct/formats/JavaClassSpecs.scala
@@ -27,14 +27,14 @@ class JavaClassSpecs(relPath: String, absPaths: Seq[String], firstSpec: ClassSpe
   private val relFiles: concurrent.Map[String, ClassSpec] = new ConcurrentHashMap[String, ClassSpec]().asScala
   private val absFiles: concurrent.Map[String, ClassSpec] = new ConcurrentHashMap[String, ClassSpec]().asScala
 
-  override def importRelative(name: String, path: List[String], inFile: Option[String]): Future[Option[ClassSpec]] = Future {
+  override def importRelative(name: String, path: List[String], inFile: String): Future[Option[ClassSpec]] = Future {
     Log.importOps.info(() => s".. importing relative $name")
     JavaClassSpecs.cached(path, inFile, relFiles, name, (_) =>
       JavaKSYParser.fileNameToSpec(s"$relPath/$name.ksy")
     )
   }
 
-  override def importAbsolute(name: String, path: List[String], inFile: Option[String]): Future[Option[ClassSpec]] = Future {
+  override def importAbsolute(name: String, path: List[String], inFile: String): Future[Option[ClassSpec]] = Future {
     Log.importOps.info(() => s".. importing absolute $name")
     JavaClassSpecs.cached(path, inFile, absFiles, name, tryAbsolutePaths)
   }
@@ -62,7 +62,7 @@ class JavaClassSpecs(relPath: String, absPaths: Seq[String], firstSpec: ClassSpe
 object JavaClassSpecs {
   def cached(
     path: List[String],
-    inFile: Option[String],
+    inFile: String,
     cacheMap: mutable.Map[String, ClassSpec],
     name: String,
     importOp: (String) => ClassSpec
@@ -80,7 +80,7 @@ object JavaClassSpecs {
           cacheMap(name) = spec
           Some(spec)
         } catch {
-          case err: Throwable => throw ErrorInInput(err, path, inFile).toException
+          case err: Throwable => throw ErrorInInput(err, path, Some(inFile)).toException
         }
     }
   }
diff --git a/shared/src/main/scala/io/kaitai/struct/format/ClassSpecs.scala b/shared/src/main/scala/io/kaitai/struct/format/ClassSpecs.scala
index ec803d136..5d36450be 100644
--- a/shared/src/main/scala/io/kaitai/struct/format/ClassSpecs.scala
+++ b/shared/src/main/scala/io/kaitai/struct/format/ClassSpecs.scala
@@ -59,6 +59,6 @@ abstract class ClassSpecs(val firstSpec: ClassSpec) extends mutable.HashMap[Stri
     }
   }
 
-  def importRelative(name: String, path: List[String], inFile: Option[String]): Future[Option[ClassSpec]]
-  def importAbsolute(name: String, path: List[String], inFile: Option[String]): Future[Option[ClassSpec]]
+  def importRelative(name: String, path: List[String], inFile: String): Future[Option[ClassSpec]]
+  def importAbsolute(name: String, path: List[String], inFile: String): Future[Option[ClassSpec]]
 }
diff --git a/shared/src/main/scala/io/kaitai/struct/precompile/LoadImports.scala b/shared/src/main/scala/io/kaitai/struct/precompile/LoadImports.scala
index 16f7ae6b3..ab6a36772 100644
--- a/shared/src/main/scala/io/kaitai/struct/precompile/LoadImports.scala
+++ b/shared/src/main/scala/io/kaitai/struct/precompile/LoadImports.scala
@@ -47,7 +47,7 @@ class LoadImports(specs: ClassSpecs) {
   private def loadImport(name: String, path: List[String], curClass: ClassSpec, workDir: ImportPath): Future[List[ClassSpec]] = {
     Log.importOps.info(() => s".. LoadImports: loadImport($name, workDir = $workDir)")
 
-    val inFile = Some(curClass.fileNameAsStr)
+    val inFile = curClass.fileNameAsStr
     val impPath = ImportPath.fromString(name)
     val fullPath = ImportPath.add(workDir, impPath)