Skip to content

Commit

Permalink
Merge branch 'main' into i18825
Browse files Browse the repository at this point in the history
  • Loading branch information
hamzaremmal authored Nov 6, 2023
2 parents 5019997 + f91e5d8 commit b0c190c
Show file tree
Hide file tree
Showing 636 changed files with 40,552 additions and 3,917 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/MainGenericRunner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ object MainGenericRunner {

case ExecuteMode.PossibleRun =>
val newClasspath = (settings.classPath :+ ".").flatMap(_.split(classpathSeparator).filter(_.nonEmpty)).map(File(_).toURI.toURL)
import dotty.tools.runner.RichClassLoader._
import dotty.tools.runner.RichClassLoader.*
val newClassLoader = ScalaClassLoader.fromURLsParallelCapable(newClasspath)
val targetToRun = settings.possibleEntryPaths.to(LazyList).find { entryPath =>
newClassLoader.tryToLoadClass(entryPath).orElse {
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/backend/jvm/BCodeAsmCommon.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ package jvm

import scala.language.unsafeNulls

import dotty.tools.dotc.core.Flags._
import dotty.tools.dotc.core.Symbols._
import dotty.tools.dotc.core.Flags.*
import dotty.tools.dotc.core.Symbols.*
import dotty.tools.dotc.report

/**
Expand Down
40 changes: 20 additions & 20 deletions compiler/src/dotty/tools/backend/jvm/BCodeBodyBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ import BCodeHelpers.InvokeStyle

import dotty.tools.dotc.ast.tpd
import dotty.tools.dotc.CompilationUnit
import dotty.tools.dotc.core.Constants._
import dotty.tools.dotc.core.Constants.*
import dotty.tools.dotc.core.Flags.{Label => LabelFlag, _}
import dotty.tools.dotc.core.Types._
import dotty.tools.dotc.core.Types.*
import dotty.tools.dotc.core.StdNames.{nme, str}
import dotty.tools.dotc.core.Symbols._
import dotty.tools.dotc.core.Symbols.*
import dotty.tools.dotc.transform.Erasure
import dotty.tools.dotc.transform.SymUtils._
import dotty.tools.dotc.util.Spans._
import dotty.tools.dotc.core.Contexts._
import dotty.tools.dotc.core.Phases._
import dotty.tools.dotc.transform.SymUtils.*
import dotty.tools.dotc.util.Spans.*
import dotty.tools.dotc.core.Contexts.*
import dotty.tools.dotc.core.Phases.*
import dotty.tools.dotc.core.Decorators.em
import dotty.tools.dotc.report

Expand All @@ -33,13 +33,13 @@ import dotty.tools.dotc.report
*
*/
trait BCodeBodyBuilder extends BCodeSkelBuilder {
// import global._
// import definitions._
import tpd._
// import global.*
// import definitions.*
import tpd.*
import int.{_, given}
import DottyBackendInterface.symExtensions
import bTypes._
import coreBTypes._
import bTypes.*
import coreBTypes.*

protected val primitives: DottyPrimitives

Expand Down Expand Up @@ -126,7 +126,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
assert(resKind.isNumericType || (resKind == BOOL),
s"$resKind is not a numeric or boolean type [operation: ${fun.symbol}]")

import ScalaPrimitivesOps._
import ScalaPrimitivesOps.*

args match {
// unary operation
Expand Down Expand Up @@ -179,7 +179,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
def genArrayOp(tree: Tree, code: Int, expectedType: BType): BType = tree match{

case Apply(DesugaredSelect(arrayObj, _), args) =>
import ScalaPrimitivesOps._
import ScalaPrimitivesOps.*
val k = tpeTK(arrayObj)
genLoad(arrayObj, k)
val elementType = typeOfArrayOp.getOrElse[bTypes.BType](code, abort(s"Unknown operation on arrays: $tree code: $code"))
Expand Down Expand Up @@ -262,7 +262,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {

val code = primitives.getPrimitive(tree, receiver.tpe)

import ScalaPrimitivesOps._
import ScalaPrimitivesOps.*

if (isArithmeticOp(code)) genArithmeticOp(tree, code)
else if (code == CONCAT) genStringConcat(tree)
Expand Down Expand Up @@ -1267,7 +1267,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {

/* Generate coercion denoted by "code" */
def genCoercion(code: Int): Unit = {
import ScalaPrimitivesOps._
import ScalaPrimitivesOps.*
(code: @switch) match {
case B2B | S2S | C2C | I2I | L2L | F2F | D2D => ()
case _ =>
Expand Down Expand Up @@ -1443,7 +1443,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
val mdescr = bmType.descriptor

val isInterface = isEmittedInterface(receiverClass)
import InvokeStyle._
import InvokeStyle.*
if (style == Super) {
if (isInterface && !method.is(JavaDefined)) {
val args = new Array[BType](bmType.argumentTypes.length + 1)
Expand Down Expand Up @@ -1497,7 +1497,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
} else if (tk.isRef) { // REFERENCE(_) | ARRAY(_)
bc.emitIF_ACMP(op, success)
} else {
import Primitives._
import Primitives.*
def useCmpG = if (negated) op == GT || op == GE else op == LT || op == LE
(tk: @unchecked) match {
case LONG => emit(asm.Opcodes.LCMP)
Expand All @@ -1512,7 +1512,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {

/* Emits code to compare (and consume) stack-top and zero using the 'op' operator */
private def genCZJUMP(success: asm.Label, failure: asm.Label, op: TestOp, tk: BType, targetIfNoJump: asm.Label, negated: Boolean = false): Unit = {
import Primitives._
import Primitives.*
if (targetIfNoJump == success) genCZJUMP(failure, success, op.negate(), tk, targetIfNoJump, negated = !negated)
else {
if (tk.isIntSizedType) { // BOOL, BYTE, CHAR, SHORT, or INT
Expand Down Expand Up @@ -1825,7 +1825,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
else
jliLambdaMetaFactoryMetafactoryHandle

bc.jmethod.visitInvokeDynamicInsn(methodName, desc, metafactory, bsmArgs: _*)
bc.jmethod.visitInvokeDynamicInsn(methodName, desc, metafactory, bsmArgs*)

generatedType
}
Expand Down
39 changes: 20 additions & 19 deletions compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,25 @@ import scala.tools.asm
import scala.tools.asm.AnnotationVisitor
import scala.tools.asm.ClassWriter
import scala.collection.mutable
import scala.compiletime.uninitialized

import dotty.tools.dotc.CompilationUnit
import dotty.tools.dotc.ast.tpd
import dotty.tools.dotc.ast.Trees
import dotty.tools.dotc.core.Annotations._
import dotty.tools.dotc.core.Constants._
import dotty.tools.dotc.core.Contexts._
import dotty.tools.dotc.core.Phases._
import dotty.tools.dotc.core.Decorators._
import dotty.tools.dotc.core.Flags._
import dotty.tools.dotc.core.Annotations.*
import dotty.tools.dotc.core.Constants.*
import dotty.tools.dotc.core.Contexts.*
import dotty.tools.dotc.core.Phases.*
import dotty.tools.dotc.core.Decorators.*
import dotty.tools.dotc.core.Flags.*
import dotty.tools.dotc.core.Names.Name
import dotty.tools.dotc.core.NameKinds.ExpandedName
import dotty.tools.dotc.core.Signature
import dotty.tools.dotc.core.StdNames._
import dotty.tools.dotc.core.StdNames.*
import dotty.tools.dotc.core.NameKinds
import dotty.tools.dotc.core.Symbols._
import dotty.tools.dotc.core.Symbols.*
import dotty.tools.dotc.core.Types
import dotty.tools.dotc.core.Types._
import dotty.tools.dotc.core.Types.*
import dotty.tools.dotc.core.TypeErasure
import dotty.tools.dotc.transform.GenericSignatures
import dotty.tools.dotc.transform.ElimErasedValueType
Expand All @@ -44,12 +45,12 @@ import dotty.tools.backend.jvm.DottyBackendInterface.symExtensions
*/
trait BCodeHelpers extends BCodeIdiomatic {
// for some reason singleton types aren't allowed in constructor calls. will need several casts in code to enforce
//import global._
import bTypes._
import tpd._
import coreBTypes._
//import global.*
import bTypes.*
import tpd.*
import coreBTypes.*
import int.{_, given}
import DottyBackendInterface._
import DottyBackendInterface.*

// We need to access GenBCode phase to get access to post-processor components.
// At this point it should always be initialized already.
Expand Down Expand Up @@ -576,7 +577,7 @@ trait BCodeHelpers extends BCodeIdiomatic {
/* builder of mirror classes */
class JMirrorBuilder extends JCommonBuilder {

private var cunit: CompilationUnit = _
private var cunit: CompilationUnit = uninitialized
def getCurrentCUnit(): CompilationUnit = cunit;

/* Generate a mirror class for a top-level module. A mirror class is a class
Expand Down Expand Up @@ -700,10 +701,10 @@ trait BCodeHelpers extends BCodeIdiomatic {
* classes.
*/
private def typeToTypeKind(tp: Type)(ct: BCodeHelpers)(storage: ct.BCInnerClassGen): ct.bTypes.BType = {
import ct.bTypes._
import ct.bTypes.*
val defn = ctx.definitions
import coreBTypes._
import Types._
import coreBTypes.*
import Types.*
/**
* Primitive types are represented as TypeRefs to the class symbol of, for example, scala.Int.
* The `primitiveTypeMap` maps those class symbols to the corresponding PrimitiveBType.
Expand Down Expand Up @@ -851,7 +852,7 @@ trait BCodeHelpers extends BCodeIdiomatic {
object BCodeHelpers {

class InvokeStyle(val style: Int) extends AnyVal {
import InvokeStyle._
import InvokeStyle.*
def isVirtual: Boolean = this == Virtual
def isStatic : Boolean = this == Static
def isSpecial: Boolean = this == Special
Expand Down
16 changes: 8 additions & 8 deletions compiler/src/dotty/tools/backend/jvm/BCodeIdiomatic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ trait BCodeIdiomatic {
val bTypes: BTypesFromSymbols[int.type]

import int.{_, given}
import bTypes._
import coreBTypes._
import bTypes.*
import coreBTypes.*


lazy val JavaStringBuilderClassName = jlStringBuilderRef.internalName
Expand Down Expand Up @@ -247,9 +247,9 @@ trait BCodeIdiomatic {
): Unit = {
jmethod.visitInvokeDynamicInsn(
"makeConcatWithConstants",
asm.Type.getMethodDescriptor(StringRef.toASMType, argTypes:_*),
asm.Type.getMethodDescriptor(StringRef.toASMType, argTypes*),
coreBTypes.jliStringConcatFactoryMakeConcatWithConstantsHandle,
(recipe +: constants):_*
(recipe +: constants)*
)
}

Expand Down Expand Up @@ -522,7 +522,7 @@ trait BCodeIdiomatic {
i += 1
}
assert(oldPos == keys.length, "emitSWITCH")
jmethod.visitTableSwitchInsn(keyMin, keyMax, defaultBranch, newBranches: _*)
jmethod.visitTableSwitchInsn(keyMin, keyMax, defaultBranch, newBranches*)
} else {
jmethod.visitLookupSwitchInsn(defaultBranch, keys, branches)
}
Expand Down Expand Up @@ -617,7 +617,7 @@ trait BCodeIdiomatic {
/* Constant-valued val-members of JCodeMethodN at the companion object, so as to avoid re-initializing them multiple times. */
object JCodeMethodN {

import asm.Opcodes._
import asm.Opcodes.*

// ---------------- conversions ----------------

Expand Down Expand Up @@ -651,7 +651,7 @@ trait BCodeIdiomatic {
* can-multi-thread
*/
final def coercionFrom(code: Int): BType = {
import ScalaPrimitivesOps._
import ScalaPrimitivesOps.*
(code: @switch) match {
case B2B | B2C | B2S | B2I | B2L | B2F | B2D => BYTE
case S2B | S2S | S2C | S2I | S2L | S2F | S2D => SHORT
Expand All @@ -668,7 +668,7 @@ trait BCodeIdiomatic {
* can-multi-thread
*/
final def coercionTo(code: Int): BType = {
import ScalaPrimitivesOps._
import ScalaPrimitivesOps.*
(code: @switch) match {
case B2B | C2B | S2B | I2B | L2B | F2B | D2B => BYTE
case B2C | C2C | S2C | I2C | L2C | F2C | D2C => CHAR
Expand Down
8 changes: 4 additions & 4 deletions compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ import dotty.tools.dotc.transform.SymUtils.*
trait BCodeSkelBuilder extends BCodeHelpers {
import int.{_, given}
import DottyBackendInterface.{symExtensions, _}
import tpd._
import bTypes._
import coreBTypes._
import bCodeAsmCommon._
import tpd.*
import bTypes.*
import coreBTypes.*
import bCodeAsmCommon.*

lazy val NativeAttr: Symbol = requiredClass[scala.native]

Expand Down
8 changes: 4 additions & 4 deletions compiler/src/dotty/tools/backend/jvm/BCodeSyncAndTry.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import scala.tools.asm

import dotty.tools.dotc.CompilationUnit
import dotty.tools.dotc.core.StdNames.nme
import dotty.tools.dotc.core.Symbols._
import dotty.tools.dotc.core.Symbols.*
import dotty.tools.dotc.ast.tpd

/*
Expand All @@ -20,9 +20,9 @@ import dotty.tools.dotc.ast.tpd
*/
trait BCodeSyncAndTry extends BCodeBodyBuilder {
import int.given
import tpd._
import bTypes._
import coreBTypes._
import tpd.*
import bTypes.*
import coreBTypes.*
/*
* Functionality to lower `synchronized` and `try` expressions.
*/
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/backend/jvm/BTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract class BTypes { self =>
def classBTypeFromInternalName(internalName: String) = classBTypeFromInternalNameMap(internalName)

val coreBTypes: CoreBTypes { val bTypes: self.type}
import coreBTypes._
import coreBTypes.*

/**
* A BType is either a primitve type, a ClassBType, an ArrayBType of one of these, or a MethodType
Expand Down
18 changes: 9 additions & 9 deletions compiler/src/dotty/tools/backend/jvm/BTypesFromSymbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import scala.annotation.threadUnsafe
import scala.collection.mutable
import scala.collection.mutable.Clearable

import dotty.tools.dotc.core.Flags._
import dotty.tools.dotc.core.Contexts._
import dotty.tools.dotc.core.Phases._
import dotty.tools.dotc.core.Symbols._
import dotty.tools.dotc.core.Flags.*
import dotty.tools.dotc.core.Contexts.*
import dotty.tools.dotc.core.Phases.*
import dotty.tools.dotc.core.Symbols.*
import dotty.tools.dotc.core.Phases.Phase
import dotty.tools.dotc.transform.SymUtils._
import dotty.tools.dotc.transform.SymUtils.*
import dotty.tools.dotc.core.StdNames
import dotty.tools.dotc.core.Phases

Expand All @@ -29,12 +29,12 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I, val frontendAcce
lazy val VolatileAttr = requiredClass[scala.volatile]

val bCodeAsmCommon: BCodeAsmCommon[int.type ] = new BCodeAsmCommon(int)
import bCodeAsmCommon._
import bCodeAsmCommon.*

val coreBTypes = new CoreBTypesFromSymbols[I]{
val bTypes: BTypesFromSymbols.this.type = BTypesFromSymbols.this
}
import coreBTypes._
import coreBTypes.*

@threadUnsafe protected lazy val classBTypeFromInternalNameMap =
collection.concurrent.TrieMap.empty[String, ClassBType]
Expand Down Expand Up @@ -286,7 +286,7 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I, val frontendAcce

val finalFlag = sym.is(Final) && !toDenot(sym).isClassConstructor && !sym.is(Mutable, butNot = Accessor) && !sym.enclosingClass.is(Trait)

import asm.Opcodes._
import asm.Opcodes.*
import GenBCodeOps.addFlagIf
0 .addFlagIf(privateFlag, ACC_PRIVATE)
.addFlagIf(!privateFlag, ACC_PUBLIC)
Expand All @@ -312,7 +312,7 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I, val frontendAcce
}

def javaFieldFlags(sym: Symbol) = {
import asm.Opcodes._
import asm.Opcodes.*
import GenBCodeOps.addFlagIf
javaFlags(sym)
.addFlagIf(sym.hasAnnotation(TransientAttr), ACC_TRANSIENT)
Expand Down
Loading

0 comments on commit b0c190c

Please sign in to comment.