Skip to content

Commit adc75a0

Browse files
committed
Convert core classes (6)
1 parent 50144f4 commit adc75a0

File tree

6 files changed

+57
-57
lines changed

6 files changed

+57
-57
lines changed

compiler/src/dotty/tools/dotc/core/Uniques.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ object Uniques {
2424
record(s"cached: $clazz")
2525
}
2626

27-
def unique[T <: Type](tp: T)(implicit ctx: Context): T = {
27+
def unique[T <: Type](tp: T)(using Context): T = {
2828
if (monitored) recordCaching(tp)
2929
if (tp.hash == NotCached) tp
3030
else if (monitored) {
@@ -56,7 +56,7 @@ object Uniques {
5656
e
5757
}
5858

59-
def enterIfNew(prefix: Type, designator: Designator, isTerm: Boolean)(implicit ctx: Context): NamedType = {
59+
def enterIfNew(prefix: Type, designator: Designator, isTerm: Boolean)(using Context): NamedType = {
6060
val h = doHash(null, designator, prefix)
6161
if (monitored) recordCaching(h, classOf[NamedType])
6262
def newType =

compiler/src/dotty/tools/dotc/core/Variances.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,22 @@ object Variances {
3737
else cut(v)
3838

3939
/** Compute variance of type parameter `tparam` in types of all symbols `sym`. */
40-
def varianceInSyms(syms: List[Symbol])(tparam: Symbol)(implicit ctx: Context): Variance =
40+
def varianceInSyms(syms: List[Symbol])(tparam: Symbol)(using Context): Variance =
4141
syms.foldLeft(Bivariant) ((v, sym) => v & varianceInSym(sym)(tparam))
4242

4343
/** Compute variance of type parameter `tparam` in type of symbol `sym`. */
44-
def varianceInSym(sym: Symbol)(tparam: Symbol)(implicit ctx: Context): Variance =
44+
def varianceInSym(sym: Symbol)(tparam: Symbol)(using Context): Variance =
4545
if (sym.isAliasType) cut(varianceInType(sym.info)(tparam))
4646
else varianceInType(sym.info)(tparam)
4747

4848
/** Compute variance of type parameter `tparam` in all types `tps`. */
49-
def varianceInTypes(tps: List[Type])(tparam: Symbol)(implicit ctx: Context): Variance =
49+
def varianceInTypes(tps: List[Type])(tparam: Symbol)(using Context): Variance =
5050
tps.foldLeft(Bivariant) ((v, tp) => v & varianceInType(tp)(tparam))
5151

5252
/** Compute variance of type parameter `tparam` in all type arguments
5353
* <code>tps</code> which correspond to formal type parameters `tparams1`.
5454
*/
55-
def varianceInArgs(tps: List[Type], tparams1: List[Symbol])(tparam: Symbol)(implicit ctx: Context): Variance = {
55+
def varianceInArgs(tps: List[Type], tparams1: List[Symbol])(tparam: Symbol)(using Context): Variance = {
5656
var v: Variance = Bivariant;
5757
for ((tp, tparam1) <- tps zip tparams1) {
5858
val v1 = varianceInType(tp)(tparam)
@@ -64,15 +64,15 @@ object Variances {
6464
}
6565

6666
/** Compute variance of type parameter `tparam` in all type annotations `annots`. */
67-
def varianceInAnnots(annots: List[Annotation])(tparam: Symbol)(implicit ctx: Context): Variance =
67+
def varianceInAnnots(annots: List[Annotation])(tparam: Symbol)(using Context): Variance =
6868
annots.foldLeft(Bivariant) ((v, annot) => v & varianceInAnnot(annot)(tparam))
6969

7070
/** Compute variance of type parameter `tparam` in type annotation `annot`. */
71-
def varianceInAnnot(annot: Annotation)(tparam: Symbol)(implicit ctx: Context): Variance =
71+
def varianceInAnnot(annot: Annotation)(tparam: Symbol)(using Context): Variance =
7272
varianceInType(annot.tree.tpe)(tparam)
7373

7474
/** Compute variance of type parameter <code>tparam</code> in type <code>tp</code>. */
75-
def varianceInType(tp: Type)(tparam: Symbol)(implicit ctx: Context): Variance = tp match {
75+
def varianceInType(tp: Type)(tparam: Symbol)(using Context): Variance = tp match {
7676
case TermRef(pre, _) =>
7777
varianceInType(pre)(tparam)
7878
case tp @ TypeRef(pre, _) =>
@@ -109,7 +109,7 @@ object Variances {
109109
Bivariant
110110
}
111111

112-
def setStructuralVariances(lam: HKTypeLambda)(implicit ctx: Context): Unit =
112+
def setStructuralVariances(lam: HKTypeLambda)(using Context): Unit =
113113
assert(!lam.isDeclaredVarianceLambda)
114114
for param <- lam.typeParams do param.storedVariance = Bivariant
115115
object narrowVariances extends TypeTraverser {
@@ -132,22 +132,22 @@ object Variances {
132132

133133
/** Does the variance of type parameter `tparam1` conform to the variance of type parameter `tparam2`?
134134
*/
135-
def varianceConforms(tparam1: TypeParamInfo, tparam2: TypeParamInfo)(implicit ctx: Context): Boolean =
135+
def varianceConforms(tparam1: TypeParamInfo, tparam2: TypeParamInfo)(using Context): Boolean =
136136
tparam1.paramVariance.isAllOf(tparam2.paramVariance)
137137

138138
/** Do the variances of type parameters `tparams1` conform to the variances
139139
* of corresponding type parameters `tparams2`?
140140
* This is only the case if `tparams1` and `tparams2` have the same length.
141141
*/
142-
def variancesConform(tparams1: List[TypeParamInfo], tparams2: List[TypeParamInfo])(implicit ctx: Context): Boolean =
142+
def variancesConform(tparams1: List[TypeParamInfo], tparams2: List[TypeParamInfo])(using Context): Boolean =
143143
val needsDetailedCheck = tparams2 match
144144
case (_: Symbol) :: _ => true
145145
case LambdaParam(tl: HKTypeLambda, _) :: _ => tl.isDeclaredVarianceLambda
146146
case _ => false
147147
if needsDetailedCheck then tparams1.corresponds(tparams2)(varianceConforms)
148148
else tparams1.hasSameLengthAs(tparams2)
149149

150-
def varianceSign(sym: Symbol)(implicit ctx: Context): String =
150+
def varianceSign(sym: Symbol)(using Context): String =
151151
varianceSign(sym.variance)
152152

153153
def varianceSign(v: Variance): String = varianceSign(varianceToInt(v))

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ object ClassfileParser {
3232
object NoEmbedded extends Embedded
3333

3434
/** Replace raw types with wildcard applications */
35-
def cook(implicit ctx: Context): TypeMap = new TypeMap {
35+
def cook(using Context): TypeMap = new TypeMap {
3636
def apply(tp: Type): Type = tp match {
3737
case tp: TypeRef if tp.symbol.typeParams.nonEmpty =>
3838
AppliedType(tp, tp.symbol.typeParams.map(Function.const(TypeBounds.empty)))
@@ -77,12 +77,12 @@ class ClassfileParser(
7777
classRoot.info = NoLoader().withDecls(instanceScope)
7878
moduleRoot.info = NoLoader().withDecls(staticScope).withSourceModule(_ => staticModule)
7979

80-
private def currentIsTopLevel(implicit ctx: Context) = classRoot.owner.is(Flags.PackageClass)
80+
private def currentIsTopLevel(using Context) = classRoot.owner.is(Flags.PackageClass)
8181

8282
private def mismatchError(className: SimpleName) =
8383
throw new IOException(s"class file '${in.file.canonicalPath}' has location not matching its contents: contains class $className")
8484

85-
def run()(implicit ctx: Context): Option[Embedded] = try {
85+
def run()(using Context): Option[Embedded] = try {
8686
ctx.debuglog("[class] >> " + classRoot.fullName)
8787
parseHeader()
8888
this.pool = new ConstantPool
@@ -110,14 +110,14 @@ class ClassfileParser(
110110
}
111111

112112
/** Return the class symbol of the given name. */
113-
def classNameToSymbol(name: Name)(implicit ctx: Context): Symbol = innerClasses.get(name) match {
113+
def classNameToSymbol(name: Name)(using Context): Symbol = innerClasses.get(name) match {
114114
case Some(entry) => innerClasses.classSymbol(entry)
115115
case None => ctx.requiredClass(name)
116116
}
117117

118118
var sawPrivateConstructor: Boolean = false
119119

120-
def parseClass()(implicit ctx: Context): Option[Embedded] = {
120+
def parseClass()(using Context): Option[Embedded] = {
121121
val jflags = in.nextChar
122122
val isAnnotation = hasAnnotation(jflags)
123123
val sflags = classTranslation.flags(jflags)
@@ -207,7 +207,7 @@ class ClassfileParser(
207207
}
208208

209209
/** Add type parameters of enclosing classes */
210-
def addEnclosingTParams()(implicit ctx: Context): Unit = {
210+
def addEnclosingTParams()(using Context): Unit = {
211211
var sym = classRoot.owner
212212
while (sym.isClass && !sym.is(Flags.ModuleClass)) {
213213
for (tparam <- sym.typeParams)
@@ -216,7 +216,7 @@ class ClassfileParser(
216216
}
217217
}
218218

219-
def parseMember(method: Boolean)(implicit ctx: Context): Unit = {
219+
def parseMember(method: Boolean)(using Context): Unit = {
220220
val start = indexCoord(in.bp)
221221
val jflags = in.nextChar
222222
val sflags =
@@ -236,7 +236,7 @@ class ClassfileParser(
236236

237237
val memberCompleter: LazyType = new LazyType {
238238

239-
def complete(denot: SymDenotation)(implicit ctx: Context): Unit = {
239+
def complete(denot: SymDenotation)(using Context): Unit = {
240240
val oldbp = in.bp
241241
try {
242242
in.bp = denot.symbol.coord.toIndex
@@ -307,7 +307,7 @@ class ClassfileParser(
307307
}
308308

309309
/** Map direct references to Object to references to Any */
310-
final def objToAny(tp: Type)(implicit ctx: Context): Type =
310+
final def objToAny(tp: Type)(using Context): Type =
311311
if (tp.isDirectRef(defn.ObjectClass) && !ctx.phase.erasedTypes) defn.AnyType else tp
312312

313313
def constantTagToType(tag: Int)(using Context): Type =
@@ -323,7 +323,7 @@ class ClassfileParser(
323323
case BOOL_TAG => defn.BooleanType
324324
}
325325

326-
private def sigToType(sig: SimpleName, owner: Symbol = null)(implicit ctx: Context): Type = {
326+
private def sigToType(sig: SimpleName, owner: Symbol = null)(using Context): Type = {
327327
var index = 0
328328
val end = sig.length
329329
def accept(ch: Char): Unit = {
@@ -337,7 +337,7 @@ class ClassfileParser(
337337
}
338338
// Warning: sigToType contains nested completers which might be forced in a later run!
339339
// So local methods need their own ctx parameters.
340-
def sig2type(tparams: immutable.Map[Name, Symbol], skiptvs: Boolean)(implicit ctx: Context): Type = {
340+
def sig2type(tparams: immutable.Map[Name, Symbol], skiptvs: Boolean)(using Context): Type = {
341341
val tag = sig(index); index += 1
342342
(tag: @switch) match {
343343
case 'L' =>
@@ -415,7 +415,7 @@ class ClassfileParser(
415415
}
416416
// sig2type(tparams, skiptvs)
417417

418-
def sig2typeBounds(tparams: immutable.Map[Name, Symbol], skiptvs: Boolean)(implicit ctx: Context): Type = {
418+
def sig2typeBounds(tparams: immutable.Map[Name, Symbol], skiptvs: Boolean)(using Context): Type = {
419419
val ts = new ListBuffer[Type]
420420
while (sig(index) == ':') {
421421
index += 1
@@ -429,7 +429,7 @@ class ClassfileParser(
429429
var tparams = classTParams
430430

431431
def typeParamCompleter(start: Int) = new LazyType {
432-
def complete(denot: SymDenotation)(implicit ctx: Context): Unit = {
432+
def complete(denot: SymDenotation)(using Context): Unit = {
433433
val savedIndex = index
434434
try {
435435
index = start
@@ -476,7 +476,7 @@ class ClassfileParser(
476476
}
477477
// sigToType
478478

479-
def parseAnnotArg(skip: Boolean = false)(implicit ctx: Context): Option[untpd.Tree] = {
479+
def parseAnnotArg(skip: Boolean = false)(using Context): Option[untpd.Tree] = {
480480

481481
// If we encounter an empty array literal, we need the type of the corresponding
482482
// parameter to properly type it, but that would require forcing the annotation
@@ -534,7 +534,7 @@ class ClassfileParser(
534534
/** Parse and return a single annotation. If it is malformed,
535535
* return None.
536536
*/
537-
def parseAnnotation(attrNameIndex: Char, skip: Boolean = false)(implicit ctx: Context): Option[Annotation] = try {
537+
def parseAnnotation(attrNameIndex: Char, skip: Boolean = false)(using Context): Option[Annotation] = try {
538538
val attrType = pool.getType(attrNameIndex)
539539
attrType match
540540
case tp: TypeRef =>
@@ -573,7 +573,7 @@ class ClassfileParser(
573573
None // ignore malformed annotations
574574
}
575575

576-
def parseAttributes(sym: Symbol, symtype: Type)(implicit ctx: Context): Type = {
576+
def parseAttributes(sym: Symbol, symtype: Type)(using Context): Type = {
577577
var newType = symtype
578578

579579
def parseAttribute(): Unit = {
@@ -662,7 +662,7 @@ class ClassfileParser(
662662
/** Annotations in Scala are assumed to get all their arguments as constructor
663663
* parameters. For Java annotations we need to fake it by making up the constructor.
664664
*/
665-
def addAnnotationConstructor(classInfo: TempClassInfoType)(implicit ctx: Context): Unit =
665+
def addAnnotationConstructor(classInfo: TempClassInfoType)(using Context): Unit =
666666
ctx.newSymbol(
667667
owner = classRoot.symbol,
668668
name = nme.CONSTRUCTOR,
@@ -671,7 +671,7 @@ class ClassfileParser(
671671
).entered
672672

673673
class AnnotConstructorCompleter(classInfo: TempClassInfoType) extends LazyType {
674-
def complete(denot: SymDenotation)(implicit ctx: Context): Unit = {
674+
def complete(denot: SymDenotation)(using Context): Unit = {
675675
val attrs = classInfo.decls.toList.filter(sym => sym.isTerm && sym != denot.symbol)
676676
val paramNames = attrs.map(_.name.asTermName)
677677
val paramTypes = attrs.map(_.info.resultType)
@@ -682,7 +682,7 @@ class ClassfileParser(
682682
/** Enter own inner classes in the right scope. It needs the scopes to be set up,
683683
* and implicitly current class' superclasses.
684684
*/
685-
private def enterOwnInnerClasses()(implicit ctx: Context): Unit = {
685+
private def enterOwnInnerClasses()(using Context): Unit = {
686686
def className(name: Name): Name = {
687687
val name1 = name.toSimpleName
688688
name1.drop(name1.lastIndexOf('.') + 1)
@@ -715,7 +715,7 @@ class ClassfileParser(
715715
* Restores the old `bp`.
716716
* @return true iff classfile is from Scala, so no Java info needs to be read.
717717
*/
718-
def unpickleOrParseInnerClasses()(implicit ctx: Context): Option[Embedded] = {
718+
def unpickleOrParseInnerClasses()(using Context): Option[Embedded] = {
719719
val oldbp = in.bp
720720
try {
721721
skipSuperclasses()
@@ -905,7 +905,7 @@ class ClassfileParser(
905905
/** Return the Symbol of the top level class enclosing `name`,
906906
* or 'name's symbol if no entry found for `name`.
907907
*/
908-
def topLevelClass(name: Name)(implicit ctx: Context): Symbol = {
908+
def topLevelClass(name: Name)(using Context): Symbol = {
909909
val tlName = if (isDefinedAt(name)) {
910910
var entry = this(name)
911911
while (isDefinedAt(entry.outerName))
@@ -920,8 +920,8 @@ class ClassfileParser(
920920
/** Return the class symbol for `entry`. It looks it up in its outer class.
921921
* This might force outer class symbols.
922922
*/
923-
def classSymbol(entry: InnerClassEntry)(implicit ctx: Context): Symbol = {
924-
def getMember(sym: Symbol, name: Name)(implicit ctx: Context): Symbol =
923+
def classSymbol(entry: InnerClassEntry)(using Context): Symbol = {
924+
def getMember(sym: Symbol, name: Name)(using Context): Symbol =
925925
if (isStatic(entry.jflags))
926926
if (sym == classRoot.symbol)
927927
staticScope.lookup(name)
@@ -977,7 +977,7 @@ class ClassfileParser(
977977
protected def getScope(flags: Int): MutableScope =
978978
if (isStatic(flags)) staticScope else instanceScope
979979

980-
private def getPrivateWithin(jflags: Int)(implicit ctx: Context): Symbol =
980+
private def getPrivateWithin(jflags: Int)(using Context): Symbol =
981981
if ((jflags & (JAVA_ACC_PRIVATE | JAVA_ACC_PUBLIC)) == 0)
982982
classRoot.enclosingPackageClass
983983
else
@@ -1048,7 +1048,7 @@ class ClassfileParser(
10481048
internalized(index)
10491049
}
10501050

1051-
def getClassSymbol(index: Int)(implicit ctx: Context): Symbol = {
1051+
def getClassSymbol(index: Int)(using Context): Symbol = {
10521052
if (index <= 0 || len <= index) errorBadIndex(index)
10531053
var c = values(index).asInstanceOf[Symbol]
10541054
if (c eq null) {
@@ -1077,7 +1077,7 @@ class ClassfileParser(
10771077
* arrays are considered to be class types, they might
10781078
* appear as entries in 'newarray' or 'cast' opcodes.
10791079
*/
1080-
def getClassOrArrayType(index: Int)(implicit ctx: Context): Type = {
1080+
def getClassOrArrayType(index: Int)(using Context): Type = {
10811081
if (index <= 0 || len <= index) errorBadIndex(index)
10821082
val value = values(index)
10831083
var c: Type = null
@@ -1102,15 +1102,15 @@ class ClassfileParser(
11021102
c
11031103
}
11041104

1105-
def getType(index: Int)(implicit ctx: Context): Type =
1105+
def getType(index: Int)(using Context): Type =
11061106
sigToType(getExternalName(index))
11071107

1108-
def getSuperClass(index: Int)(implicit ctx: Context): Symbol = {
1108+
def getSuperClass(index: Int)(using Context): Symbol = {
11091109
assert(index != 0, "attempt to parse java.lang.Object from classfile")
11101110
getClassSymbol(index)
11111111
}
11121112

1113-
def getConstant(index: Int, pt: Type = WildcardType)(implicit ctx: Context): Constant = {
1113+
def getConstant(index: Int, pt: Type = WildcardType)(using Context): Constant = {
11141114
if (index <= 0 || len <= index) errorBadIndex(index)
11151115
var value = values(index)
11161116
if (value eq null) {

0 commit comments

Comments
 (0)