Skip to content

Commit

Permalink
Fix comment and remove spurious end-of-line whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
WojciechMazur committed Jun 27, 2022
1 parent e412269 commit 0b96142
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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]

/**
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/backend/jvm/BackendUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions compiler/src/dotty/tools/backend/jvm/ClassfileWriter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
}

Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
8 changes: 4 additions & 4 deletions compiler/src/dotty/tools/backend/jvm/PostProcessor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 0b96142

Please sign in to comment.