Skip to content

Commit aa64078

Browse files
authored
Merge pull request #9333 from dotty-staging/change-using
Change implicit to using
2 parents e6bb414 + 159486a commit aa64078

File tree

323 files changed

+3976
-5983
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

323 files changed

+3976
-5983
lines changed

compiler/src/dotty/tools/backend/jvm/BCodeAsmCommon.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import dotty.tools.dotc.core.Symbols._
1010
* the compiler cake (Global).
1111
*/
1212
final class BCodeAsmCommon[I <: DottyBackendInterface](val interface: I) {
13-
import interface._
13+
import interface.{_, given _}
1414
import DottyBackendInterface.symExtensions
1515

1616
/**

compiler/src/dotty/tools/backend/jvm/BCodeBodyBuilder.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import dotty.tools.dotc.core.Symbols._
1919
import dotty.tools.dotc.transform.Erasure
2020
import dotty.tools.dotc.transform.SymUtils._
2121
import dotty.tools.dotc.util.Spans._
22+
import dotty.tools.dotc.core.Contexts.{inContext, atPhase}
23+
import dotty.tools.dotc.core.Phases._
2224

2325
/*
2426
*
@@ -30,7 +32,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
3032
// import global._
3133
// import definitions._
3234
import tpd._
33-
import int._
35+
import int.{_, given _}
3436
import DottyBackendInterface.symExtensions
3537
import bTypes._
3638
import coreBTypes._
@@ -1460,7 +1462,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
14601462
// TODO specialization
14611463
val constrainedType = new MethodBType(lambdaParamTypes.map(p => toTypeKind(p)), toTypeKind(lambdaTarget.info.resultType)).toASMType
14621464

1463-
val abstractMethod = ctx.atPhase(ctx.erasurePhase) {
1465+
val abstractMethod = atPhase(erasurePhase) {
14641466
val samMethods = toDenot(functionalInterface).info.possibleSamMethods.toList
14651467
samMethods match {
14661468
case x :: Nil => x.symbol

compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import dotty.tools.dotc.ast.tpd
1313
import dotty.tools.dotc.ast.Trees
1414
import dotty.tools.dotc.core.Annotations._
1515
import dotty.tools.dotc.core.Constants._
16-
import dotty.tools.dotc.core.Contexts.Context
16+
import dotty.tools.dotc.core.Contexts.{Context, atPhase}
17+
import dotty.tools.dotc.core.Phases._
1718
import dotty.tools.dotc.core.Decorators._
1819
import dotty.tools.dotc.core.Flags._
1920
import dotty.tools.dotc.core.Names.Name
@@ -45,7 +46,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
4546
import bTypes._
4647
import tpd._
4748
import coreBTypes._
48-
import int._
49+
import int.{_, given _}
4950
import DottyBackendInterface._
5051

5152
def ScalaATTRName: String = "Scala"
@@ -360,7 +361,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
360361
val narg = normalizeArgument(arg)
361362
// Transformation phases are not run on annotation trees, so we need to run
362363
// `constToLiteral` at this point.
363-
val t = constToLiteral(narg)(ctx.withPhase(ctx.erasurePhase))
364+
val t = atPhase(erasurePhase)(constToLiteral(narg))
364365
t match {
365366
case Literal(const @ Constant(_)) =>
366367
const.tag match {
@@ -464,7 +465,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
464465
} // end of trait BCAnnotGen
465466

466467
trait BCJGenSigGen {
467-
import int._
468+
import int.{_, given _}
468469

469470
def getCurrentCUnit(): CompilationUnit
470471

@@ -478,7 +479,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
478479
* @see https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.3.4
479480
*/
480481
def getGenericSignature(sym: Symbol, owner: Symbol): String = {
481-
ctx.atPhase(ctx.erasurePhase) {
482+
atPhase(erasurePhase) {
482483
val memberTpe =
483484
if (sym.is(Method)) sym.denot.info
484485
else owner.denot.thisType.memberInfo(sym)
@@ -844,7 +845,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
844845
}
845846
}
846847

847-
private def getGenericSignatureHelper(sym: Symbol, owner: Symbol, memberTpe: Type)(implicit ctx: Context): Option[String] = {
848+
private def getGenericSignatureHelper(sym: Symbol, owner: Symbol, memberTpe: Type)(using Context): Option[String] = {
848849
if (needsGenericSignature(sym)) {
849850
val erasedTypeSym = TypeErasure.fullErasure(sym.denot.info).typeSymbol
850851
if (erasedTypeSym.isPrimitiveValueClass) {
@@ -864,7 +865,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
864865
}
865866
}
866867

867-
private def verifySignature(sym: Symbol, sig: String)(implicit ctx: Context): Unit = {
868+
private def verifySignature(sym: Symbol, sig: String)(using Context): Unit = {
868869
import scala.tools.asm.util.CheckClassAdapter
869870
def wrap(body: => Unit): Unit = {
870871
try body
@@ -913,7 +914,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
913914
// But for now, just like we did in mixin, we just avoid writing a wrong generic signature
914915
// (one that doesn't erase to the actual signature). See run/t3452b for a test case.
915916

916-
val memberTpe = ctx.atPhase(ctx.erasurePhase) { moduleClass.denot.thisType.memberInfo(sym) }
917+
val memberTpe = atPhase(erasurePhase) { moduleClass.denot.thisType.memberInfo(sym) }
917918
val erasedMemberType = TypeErasure.erasure(memberTpe)
918919
if (erasedMemberType =:= sym.denot.info)
919920
getGenericSignatureHelper(sym, moduleClass, memberTpe).orNull

compiler/src/dotty/tools/backend/jvm/BCodeIdiomatic.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ trait BCodeIdiomatic {
1919
val int: DottyBackendInterface
2020
final lazy val bTypes = new BTypesFromSymbols[int.type](int)
2121

22-
import int._
22+
import int.{_, given _}
2323
import bTypes._
2424
import coreBTypes._
2525

compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import dotty.tools.dotc.util.Spans._
2626
*
2727
*/
2828
trait BCodeSkelBuilder extends BCodeHelpers {
29-
import int._
29+
import int.{_, given _}
3030
import DottyBackendInterface.{symExtensions, _}
3131
import tpd._
3232
import bTypes._

compiler/src/dotty/tools/backend/jvm/BCodeSyncAndTry.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import dotty.tools.dotc.ast.tpd.TreeOps
1818
*
1919
*/
2020
trait BCodeSyncAndTry extends BCodeBodyBuilder {
21-
import int._
21+
import int.{_, given _}
2222
import tpd._
2323
import bTypes._
2424
import coreBTypes._

compiler/src/dotty/tools/backend/jvm/BTypes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import scala.tools.asm
1515
abstract class BTypes {
1616

1717
val int: DottyBackendInterface
18-
import int._
18+
import int.{_, given _}
1919
/**
2020
* A map from internal names to ClassBTypes. Every ClassBType is added to this map on its
2121
* construction.

compiler/src/dotty/tools/backend/jvm/BTypesFromSymbols.scala

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import scala.collection.mutable
88
import scala.collection.generic.Clearable
99

1010
import dotty.tools.dotc.core.Flags._
11+
import dotty.tools.dotc.core.Contexts.{inContext, atPhase}
12+
import dotty.tools.dotc.core.Phases._
1113
import dotty.tools.dotc.core.Symbols._
1214
import dotty.tools.dotc.core.Phases.Phase
1315
import dotty.tools.dotc.transform.SymUtils._
@@ -26,7 +28,7 @@ import dotty.tools.dotc.util.WeakHashSet
2628
* not have access to the compiler instance.
2729
*/
2830
class BTypesFromSymbols[I <: DottyBackendInterface](val int: I) extends BTypes {
29-
import int._
31+
import int.{_, given _}
3032
import DottyBackendInterface.{symExtensions, _}
3133

3234
lazy val TransientAttr = requiredClass[scala.transient]
@@ -202,16 +204,16 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I) extends BTypes {
202204
/** For currently compiled classes: All locally defined classes including local classes.
203205
* The empty list for classes that are not currently compiled.
204206
*/
205-
private def getNestedClasses(sym: Symbol): List[Symbol] = definedClasses(sym, ctx.flattenPhase)
207+
private def getNestedClasses(sym: Symbol): List[Symbol] = definedClasses(sym, flattenPhase)
206208

207209
/** For currently compiled classes: All classes that are declared as members of this class
208210
* (but not inherited ones). The empty list for classes that are not currently compiled.
209211
*/
210-
private def getMemberClasses(sym: Symbol): List[Symbol] = definedClasses(sym, ctx.lambdaLiftPhase)
212+
private def getMemberClasses(sym: Symbol): List[Symbol] = definedClasses(sym, lambdaLiftPhase)
211213

212214
private def definedClasses(sym: Symbol, phase: Phase) =
213215
if (sym.isDefinedInCurrentRun)
214-
ctx.atPhase(phase) {
216+
atPhase(phase) {
215217
toDenot(sym).info.decls.filter(_.isClass)
216218
}
217219
else Nil
@@ -228,10 +230,11 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I) extends BTypes {
228230
// After lambdalift (which is where we are), the rawowoner field contains the enclosing class.
229231
val enclosingClassSym = {
230232
if (innerClassSym.isClass) {
231-
val ct = ctx.withPhase(ctx.flattenPhase.prev)
232-
toDenot(innerClassSym)(ct).owner.enclosingClass(ct)
233+
atPhase(flattenPhase.prev) {
234+
toDenot(innerClassSym).owner.enclosingClass
235+
}
233236
}
234-
else innerClassSym.enclosingClass(ctx.withPhase(ctx.flattenPhase.prev))
237+
else atPhase(flattenPhase.prev)(innerClassSym.enclosingClass)
235238
} //todo is handled specially for JavaDefined symbols in scalac
236239

237240
val enclosingClass: ClassBType = classBTypeFromSymbol(enclosingClassSym)
@@ -255,7 +258,7 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I) extends BTypes {
255258
if (innerClassSym.isAnonymousClass || innerClassSym.isAnonymousFunction) None
256259
else {
257260
val original = innerClassSym.initial
258-
Some(innerClassSym.name(ctx.withPhase(original.validFor.phaseId)).mangledString) // moduleSuffix for module classes
261+
Some(atPhase(original.validFor.phaseId)(innerClassSym.name).mangledString) // moduleSuffix for module classes
259262
}
260263
}
261264

compiler/src/dotty/tools/backend/jvm/BytecodeWriters.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class FileConflictException(msg: String, val file: AbstractFile) extends IOExcep
1616
*/
1717
trait BytecodeWriters {
1818
val int: DottyBackendInterface
19-
import int._
19+
import int.{_, given _}
2020

2121
/**
2222
* @param clsName cls.getName

compiler/src/dotty/tools/backend/jvm/CollectSuperCalls.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package dotty.tools.backend.jvm
22

33
import dotty.tools.dotc.ast.tpd
4-
import dotty.tools.dotc.core.Contexts.Context
4+
import dotty.tools.dotc.core.Contexts.{Context, ctx}
5+
import dotty.tools.dotc.core.Phases._
56
import dotty.tools.dotc.core.Symbols._
67
import dotty.tools.dotc.core.Flags.Trait
78
import dotty.tools.dotc.transform.MegaPhase.MiniPhase
@@ -21,7 +22,7 @@ class CollectSuperCalls extends MiniPhase {
2122

2223
def phaseName: String = "collectSuperCalls"
2324

24-
override def transformSelect(tree: Select)(implicit ctx: Context): Tree = {
25+
override def transformSelect(tree: Select)(using Context): Tree = {
2526
tree.qualifier match {
2627
case sup: Super =>
2728
if (tree.symbol.owner.is(Trait))
@@ -31,8 +32,8 @@ class CollectSuperCalls extends MiniPhase {
3132
tree
3233
}
3334

34-
private def registerSuperCall(sym: ClassSymbol, calls: ClassSymbol)(implicit ctx: Context) = {
35-
ctx.genBCodePhase match {
35+
private def registerSuperCall(sym: ClassSymbol, calls: ClassSymbol)(using Context) = {
36+
genBCodePhase match {
3637
case genBCodePhase: GenBCode =>
3738
genBCodePhase.registerSuperCall(sym, calls)
3839
case _ =>

0 commit comments

Comments
 (0)