diff --git a/compiler/src/dotty/tools/backend/jvm/BTypesFromSymbols.scala b/compiler/src/dotty/tools/backend/jvm/BTypesFromSymbols.scala index 81e015578168..4285917ed755 100644 --- a/compiler/src/dotty/tools/backend/jvm/BTypesFromSymbols.scala +++ b/compiler/src/dotty/tools/backend/jvm/BTypesFromSymbols.scala @@ -36,7 +36,7 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I, val frontendAcce } import coreBTypes._ - @threadUnsafe protected lazy val classBTypeFromInternalNameMap = + @threadUnsafe protected lazy val classBTypeFromInternalNameMap = collection.concurrent.TrieMap.empty[String, ClassBType] /** diff --git a/compiler/src/dotty/tools/backend/jvm/BackendUtils.scala b/compiler/src/dotty/tools/backend/jvm/BackendUtils.scala index 1613efd0d3f6..b6aab1523358 100644 --- a/compiler/src/dotty/tools/backend/jvm/BackendUtils.scala +++ b/compiler/src/dotty/tools/backend/jvm/BackendUtils.scala @@ -35,7 +35,7 @@ class BackendUtils(val postProcessor: PostProcessor) { case "18" => asm.Opcodes.V18 case "19" => asm.Opcodes.V19 } - + lazy val extraProc: Int = { import GenBCodeOps.addFlagIf val majorVersion: Int = (classfileVersion & 0xFF) @@ -160,7 +160,7 @@ class BackendUtils(val postProcessor: PostProcessor) { * `refedInnerClasses` may contain duplicates, need not contain the enclosing inner classes of * each inner class it lists (those are looked up and included). * - * This method serializes in the InnerClasses JVM attribute in an appropriate order, + * This method serializes in the InnerClasses JVM attribute in an appropriate order, * not necessarily that given by `refedInnerClasses`. * * can-multi-thread diff --git a/compiler/src/dotty/tools/backend/jvm/ClassfileWriter.scala b/compiler/src/dotty/tools/backend/jvm/ClassfileWriter.scala index 947d4e62e5e6..2ebcb27750c0 100644 --- a/compiler/src/dotty/tools/backend/jvm/ClassfileWriter.scala +++ b/compiler/src/dotty/tools/backend/jvm/ClassfileWriter.scala @@ -15,7 +15,7 @@ import scala.language.unsafeNulls class ClassfileWriter(frontendAccess: PostProcessorFrontendAccess) { import frontendAccess.{backendReporting, compilerSettings} - + // if non-null, classfiles are additionally written to this directory private val dumpOutputDir: AbstractFile = getDirectoryOrNull(compilerSettings.dumpClassesDirectory) @@ -35,17 +35,17 @@ class ClassfileWriter(frontendAccess: PostProcessorFrontendAccess) { None } } - jar.underlyingSource.map{ source => - if jar.isEmpty then + jar.underlyingSource.map{ source => + if jar.isEmpty then val jarMainAttrs = mainClass.map(Name.MAIN_CLASS -> _).toList new Jar(source.file).jarWriter(jarMainAttrs: _*) else - // Writing to non-empty JAR might be an undefined behaviour, e.g. in case if other files where + // Writing to non-empty JAR might be an undefined behaviour, e.g. in case if other files where // created using `AbstractFile.bufferedOutputStream`instead of JarWritter backendReporting.warning(s"Tried to write to non-empty JAR: $source") null }.orNull - + case _ => null } @@ -113,7 +113,7 @@ class ClassfileWriter(frontendAccess: PostProcessorFrontendAccess) { def writeTasty(className: InternalName, bytes: Array[Byte]): Unit = writeToJarOrFile(className, bytes, ".tasty") - + private def writeToJarOrFile(className: InternalName, bytes: Array[Byte], suffix: String): AbstractFile | Null = { if jarWriter == null then val outFolder = compilerSettings.outputDirectory @@ -124,7 +124,7 @@ class ClassfileWriter(frontendAccess: PostProcessorFrontendAccess) { catch case _: Throwable => () finally throw ex outFile - else + else val path = className + suffix val out = jarWriter.newOutputStream(path) try out.write(bytes, 0, bytes.length) diff --git a/compiler/src/dotty/tools/backend/jvm/GenericSignatureVisitor.scala b/compiler/src/dotty/tools/backend/jvm/GenericSignatureVisitor.scala index e9e532933290..c16bc70fc3b0 100644 --- a/compiler/src/dotty/tools/backend/jvm/GenericSignatureVisitor.scala +++ b/compiler/src/dotty/tools/backend/jvm/GenericSignatureVisitor.scala @@ -185,13 +185,13 @@ abstract class GenericSignatureVisitor(nestedOnly: Boolean) { } // Backported from scala/scala, commit sha: 724be0e9425b9ad07c244d25efdad695d75abbcf -// https://github.com/scala/scala/blob/724be0e9425b9ad07c244d25efdad695d75abbcf/src/compiler/scala/tools/nsc/backend/jvm/analysis/BackendUtils.scala#L790 +// https://github.com/scala/scala/blob/724be0e9425b9ad07c244d25efdad695d75abbcf/src/compiler/scala/tools/nsc/backend/jvm/analysis/BackendUtils.scala#L790 abstract class NestedClassesCollector[T](nestedOnly: Boolean) extends GenericSignatureVisitor(nestedOnly) { - type InternalName = String + type InternalName = String def declaredNestedClasses(internalName: InternalName): List[T] def getClassIfNested(internalName: InternalName): Option[T] - + val declaredInnerClasses = mutable.Set.empty[T] val referredInnerClasses = mutable.Set.empty[T] diff --git a/compiler/src/dotty/tools/backend/jvm/PostProcessor.scala b/compiler/src/dotty/tools/backend/jvm/PostProcessor.scala index 98e3b8ceefcb..463ff57f9a0f 100644 --- a/compiler/src/dotty/tools/backend/jvm/PostProcessor.scala +++ b/compiler/src/dotty/tools/backend/jvm/PostProcessor.scala @@ -16,19 +16,19 @@ class PostProcessor(val frontendAccess: PostProcessorFrontendAccess, val bTypes: import bTypes.* import frontendAccess.{backendReporting, compilerSettings} import int.given - + val backendUtils = new BackendUtils(this) val classfileWriter = ClassfileWriter(frontendAccess) def postProcessAndSendToDisk(generatedDefs: GeneratedDefs): Unit = { val GeneratedDefs(classes, tasty) = generatedDefs for (GeneratedClass(classNode, sourceFile, isArtifact, onFileCreated) <- classes) { - val bytes = - try + val bytes = + try if !isArtifact then setSerializableLambdas(classNode) setInnerClasses(classNode) serializeClass(classNode) - catch + catch case e: java.lang.RuntimeException if e.getMessage != null && e.getMessage.nn.contains("too large!") => backendReporting.error(s"Could not write class ${classNode.name} because it exceeds JVM code size limits. ${e.getMessage}") null diff --git a/compiler/src/dotty/tools/backend/jvm/PostProcessorFrontendAccess.scala b/compiler/src/dotty/tools/backend/jvm/PostProcessorFrontendAccess.scala index 041930680bc3..c447dc7d4aa3 100644 --- a/compiler/src/dotty/tools/backend/jvm/PostProcessorFrontendAccess.scala +++ b/compiler/src/dotty/tools/backend/jvm/PostProcessorFrontendAccess.scala @@ -46,7 +46,7 @@ object PostProcessorFrontendAccess { private def buildCompilerSettings(): CompilerSettings = new CompilerSettings { extension [T](s: dotty.tools.dotc.config.Settings.Setting[T]) - def valueSetByUser: Option[T] = + def valueSetByUser: Option[T] = Option(s.value).filter(_ != s.default) def s = ctx.settings diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index 8a66b5abca8a..3893c3ba3d73 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -15,7 +15,7 @@ import scala.util.chaining._ class ScalaSettings extends SettingGroup with AllScalaSettings object ScalaSettings: - // Keep synchronized with `classfileVersion` in `BCodeIdiomatic` + // Keep synchronized with `classfileVersion` in `BackendUtils` private val minTargetVersion = 8 private val maxTargetVersion = 19