Skip to content

Commit

Permalink
Merge pull request #274 from Mingun/fix-deprecation-warnings
Browse files Browse the repository at this point in the history
Fix deprecation warnings from Scala 2.13.0
  • Loading branch information
GreyCat authored Mar 10, 2024
2 parents 495037c + 49970b6 commit 6aef6fa
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object JavaScriptKSYParser {
case _: String | _: Int | _: Double | _: Boolean =>
src
case dict =>
dict.asInstanceOf[js.Dictionary[AnyRef]].toMap.mapValues(yamlJavascriptToScala)
dict.asInstanceOf[js.Dictionary[AnyRef]].toMap.view.mapValues(yamlJavascriptToScala).toMap
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import io.kaitai.struct.{Log, Main}
import org.yaml.snakeyaml.error.MarkedYAMLException
import org.yaml.snakeyaml.{LoaderOptions, Yaml}

import scala.collection.JavaConverters._
import scala.concurrent.Await
import scala.concurrent.duration.Duration
import scala.jdk.CollectionConverters._

object JavaKSYParser {
def localFileToSpecs(yamlFilename: String, config: CLIConfig): (Option[ClassSpecs], Iterable[CompilationProblem]) = {
Expand Down
10 changes: 6 additions & 4 deletions shared/src/main/scala/io/kaitai/struct/Utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,23 @@ object Utils {
if (s.isEmpty) {
s
} else {
s.charAt(0).toUpper + s.substring(1)
s.charAt(0).toUpper.toString + s.substring(1)
}
}

/**
* Joins collection together to make a single string. Makes extra exception for empty
* collections (not like [[TraversableOnce]] `mkString`).
* collections (not like [[IterableOnce]] `mkString`).
* @param start the starting string.
* @param sep the separator string.
* @param end the ending string.
* @return If the collection is empty, returns empty string, otherwise returns `start`,
* then elements of the collection, every pair separated with `sep`, then `end`.
*/
def join[T](coll: TraversableOnce[T], start: String, sep: String, end: String): String =
if (coll.isEmpty) "" else coll.mkString(start, sep, end)
def join[T](coll: IterableOnce[T], start: String, sep: String, end: String): String = {
val it = coll.iterator
if (it.isEmpty) "" else it.mkString(start, sep, end)
}

/**
* Converts byte array (Seq[Byte]) into hex-escaped C-style literal characters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ object KSVersion {
*/
private var _current: Option[KSVersion] = None

def current_=(str: String) {
def current_=(str: String): Unit = {
_current = Some(KSVersion.fromStr(str))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class PerlCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
out.puts
}

override def classConstructorFooter(): Unit = {
override def classConstructorFooter: Unit = {
out.puts
out.puts("return $self;")
universalFooter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ abstract class LanguageCompiler(
def instanceFooter: Unit
def instanceCheckCacheAndReturn(instName: InstanceIdentifier, dataType: DataType): Unit
def instanceReturn(instName: InstanceIdentifier, attrType: DataType): Unit
def instanceCalculate(instName: Identifier, dataType: DataType, value: Ast.expr)
def instanceCalculate(instName: Identifier, dataType: DataType, value: Ast.expr): Unit

def enumDeclaration(curClass: List[String], enumName: String, enumColl: Seq[(Long, EnumValueSpec)]): Unit

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ trait UniversalDoc extends LanguageCompiler {
override def classDoc(name: List[String], doc: DocSpec) = universalDoc(doc)
override def attributeDoc(id: Identifier, doc: DocSpec) = universalDoc(doc)

def universalDoc(doc: DocSpec)
def universalDoc(doc: DocSpec): Unit
}

0 comments on commit 6aef6fa

Please sign in to comment.