@@ -32,7 +32,7 @@ object ClassfileParser {
32
32
object NoEmbedded extends Embedded
33
33
34
34
/** Replace raw types with wildcard applications */
35
- def cook (implicit ctx : Context ): TypeMap = new TypeMap {
35
+ def cook (using Context ): TypeMap = new TypeMap {
36
36
def apply (tp : Type ): Type = tp match {
37
37
case tp : TypeRef if tp.symbol.typeParams.nonEmpty =>
38
38
AppliedType (tp, tp.symbol.typeParams.map(Function .const(TypeBounds .empty)))
@@ -77,12 +77,12 @@ class ClassfileParser(
77
77
classRoot.info = NoLoader ().withDecls(instanceScope)
78
78
moduleRoot.info = NoLoader ().withDecls(staticScope).withSourceModule(_ => staticModule)
79
79
80
- private def currentIsTopLevel (implicit ctx : Context ) = classRoot.owner.is(Flags .PackageClass )
80
+ private def currentIsTopLevel (using Context ) = classRoot.owner.is(Flags .PackageClass )
81
81
82
82
private def mismatchError (className : SimpleName ) =
83
83
throw new IOException (s " class file ' ${in.file.canonicalPath}' has location not matching its contents: contains class $className" )
84
84
85
- def run ()(implicit ctx : Context ): Option [Embedded ] = try {
85
+ def run ()(using Context ): Option [Embedded ] = try {
86
86
ctx.debuglog(" [class] >> " + classRoot.fullName)
87
87
parseHeader()
88
88
this .pool = new ConstantPool
@@ -110,14 +110,14 @@ class ClassfileParser(
110
110
}
111
111
112
112
/** 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 {
114
114
case Some (entry) => innerClasses.classSymbol(entry)
115
115
case None => ctx.requiredClass(name)
116
116
}
117
117
118
118
var sawPrivateConstructor : Boolean = false
119
119
120
- def parseClass ()(implicit ctx : Context ): Option [Embedded ] = {
120
+ def parseClass ()(using Context ): Option [Embedded ] = {
121
121
val jflags = in.nextChar
122
122
val isAnnotation = hasAnnotation(jflags)
123
123
val sflags = classTranslation.flags(jflags)
@@ -207,7 +207,7 @@ class ClassfileParser(
207
207
}
208
208
209
209
/** Add type parameters of enclosing classes */
210
- def addEnclosingTParams ()(implicit ctx : Context ): Unit = {
210
+ def addEnclosingTParams ()(using Context ): Unit = {
211
211
var sym = classRoot.owner
212
212
while (sym.isClass && ! sym.is(Flags .ModuleClass )) {
213
213
for (tparam <- sym.typeParams)
@@ -216,7 +216,7 @@ class ClassfileParser(
216
216
}
217
217
}
218
218
219
- def parseMember (method : Boolean )(implicit ctx : Context ): Unit = {
219
+ def parseMember (method : Boolean )(using Context ): Unit = {
220
220
val start = indexCoord(in.bp)
221
221
val jflags = in.nextChar
222
222
val sflags =
@@ -236,7 +236,7 @@ class ClassfileParser(
236
236
237
237
val memberCompleter : LazyType = new LazyType {
238
238
239
- def complete (denot : SymDenotation )(implicit ctx : Context ): Unit = {
239
+ def complete (denot : SymDenotation )(using Context ): Unit = {
240
240
val oldbp = in.bp
241
241
try {
242
242
in.bp = denot.symbol.coord.toIndex
@@ -307,7 +307,7 @@ class ClassfileParser(
307
307
}
308
308
309
309
/** 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 =
311
311
if (tp.isDirectRef(defn.ObjectClass ) && ! ctx.phase.erasedTypes) defn.AnyType else tp
312
312
313
313
def constantTagToType (tag : Int )(using Context ): Type =
@@ -323,7 +323,7 @@ class ClassfileParser(
323
323
case BOOL_TAG => defn.BooleanType
324
324
}
325
325
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 = {
327
327
var index = 0
328
328
val end = sig.length
329
329
def accept (ch : Char ): Unit = {
@@ -337,7 +337,7 @@ class ClassfileParser(
337
337
}
338
338
// Warning: sigToType contains nested completers which might be forced in a later run!
339
339
// 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 = {
341
341
val tag = sig(index); index += 1
342
342
(tag : @ switch) match {
343
343
case 'L' =>
@@ -415,7 +415,7 @@ class ClassfileParser(
415
415
}
416
416
// sig2type(tparams, skiptvs)
417
417
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 = {
419
419
val ts = new ListBuffer [Type ]
420
420
while (sig(index) == ':' ) {
421
421
index += 1
@@ -429,7 +429,7 @@ class ClassfileParser(
429
429
var tparams = classTParams
430
430
431
431
def typeParamCompleter (start : Int ) = new LazyType {
432
- def complete (denot : SymDenotation )(implicit ctx : Context ): Unit = {
432
+ def complete (denot : SymDenotation )(using Context ): Unit = {
433
433
val savedIndex = index
434
434
try {
435
435
index = start
@@ -476,7 +476,7 @@ class ClassfileParser(
476
476
}
477
477
// sigToType
478
478
479
- def parseAnnotArg (skip : Boolean = false )(implicit ctx : Context ): Option [untpd.Tree ] = {
479
+ def parseAnnotArg (skip : Boolean = false )(using Context ): Option [untpd.Tree ] = {
480
480
481
481
// If we encounter an empty array literal, we need the type of the corresponding
482
482
// parameter to properly type it, but that would require forcing the annotation
@@ -534,7 +534,7 @@ class ClassfileParser(
534
534
/** Parse and return a single annotation. If it is malformed,
535
535
* return None.
536
536
*/
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 {
538
538
val attrType = pool.getType(attrNameIndex)
539
539
attrType match
540
540
case tp : TypeRef =>
@@ -573,7 +573,7 @@ class ClassfileParser(
573
573
None // ignore malformed annotations
574
574
}
575
575
576
- def parseAttributes (sym : Symbol , symtype : Type )(implicit ctx : Context ): Type = {
576
+ def parseAttributes (sym : Symbol , symtype : Type )(using Context ): Type = {
577
577
var newType = symtype
578
578
579
579
def parseAttribute (): Unit = {
@@ -662,7 +662,7 @@ class ClassfileParser(
662
662
/** Annotations in Scala are assumed to get all their arguments as constructor
663
663
* parameters. For Java annotations we need to fake it by making up the constructor.
664
664
*/
665
- def addAnnotationConstructor (classInfo : TempClassInfoType )(implicit ctx : Context ): Unit =
665
+ def addAnnotationConstructor (classInfo : TempClassInfoType )(using Context ): Unit =
666
666
ctx.newSymbol(
667
667
owner = classRoot.symbol,
668
668
name = nme.CONSTRUCTOR ,
@@ -671,7 +671,7 @@ class ClassfileParser(
671
671
).entered
672
672
673
673
class AnnotConstructorCompleter (classInfo : TempClassInfoType ) extends LazyType {
674
- def complete (denot : SymDenotation )(implicit ctx : Context ): Unit = {
674
+ def complete (denot : SymDenotation )(using Context ): Unit = {
675
675
val attrs = classInfo.decls.toList.filter(sym => sym.isTerm && sym != denot.symbol)
676
676
val paramNames = attrs.map(_.name.asTermName)
677
677
val paramTypes = attrs.map(_.info.resultType)
@@ -682,7 +682,7 @@ class ClassfileParser(
682
682
/** Enter own inner classes in the right scope. It needs the scopes to be set up,
683
683
* and implicitly current class' superclasses.
684
684
*/
685
- private def enterOwnInnerClasses ()(implicit ctx : Context ): Unit = {
685
+ private def enterOwnInnerClasses ()(using Context ): Unit = {
686
686
def className (name : Name ): Name = {
687
687
val name1 = name.toSimpleName
688
688
name1.drop(name1.lastIndexOf('.' ) + 1 )
@@ -715,7 +715,7 @@ class ClassfileParser(
715
715
* Restores the old `bp`.
716
716
* @return true iff classfile is from Scala, so no Java info needs to be read.
717
717
*/
718
- def unpickleOrParseInnerClasses ()(implicit ctx : Context ): Option [Embedded ] = {
718
+ def unpickleOrParseInnerClasses ()(using Context ): Option [Embedded ] = {
719
719
val oldbp = in.bp
720
720
try {
721
721
skipSuperclasses()
@@ -905,7 +905,7 @@ class ClassfileParser(
905
905
/** Return the Symbol of the top level class enclosing `name`,
906
906
* or 'name's symbol if no entry found for `name`.
907
907
*/
908
- def topLevelClass (name : Name )(implicit ctx : Context ): Symbol = {
908
+ def topLevelClass (name : Name )(using Context ): Symbol = {
909
909
val tlName = if (isDefinedAt(name)) {
910
910
var entry = this (name)
911
911
while (isDefinedAt(entry.outerName))
@@ -920,8 +920,8 @@ class ClassfileParser(
920
920
/** Return the class symbol for `entry`. It looks it up in its outer class.
921
921
* This might force outer class symbols.
922
922
*/
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 =
925
925
if (isStatic(entry.jflags))
926
926
if (sym == classRoot.symbol)
927
927
staticScope.lookup(name)
@@ -977,7 +977,7 @@ class ClassfileParser(
977
977
protected def getScope (flags : Int ): MutableScope =
978
978
if (isStatic(flags)) staticScope else instanceScope
979
979
980
- private def getPrivateWithin (jflags : Int )(implicit ctx : Context ): Symbol =
980
+ private def getPrivateWithin (jflags : Int )(using Context ): Symbol =
981
981
if ((jflags & (JAVA_ACC_PRIVATE | JAVA_ACC_PUBLIC )) == 0 )
982
982
classRoot.enclosingPackageClass
983
983
else
@@ -1048,7 +1048,7 @@ class ClassfileParser(
1048
1048
internalized(index)
1049
1049
}
1050
1050
1051
- def getClassSymbol (index : Int )(implicit ctx : Context ): Symbol = {
1051
+ def getClassSymbol (index : Int )(using Context ): Symbol = {
1052
1052
if (index <= 0 || len <= index) errorBadIndex(index)
1053
1053
var c = values(index).asInstanceOf [Symbol ]
1054
1054
if (c eq null ) {
@@ -1077,7 +1077,7 @@ class ClassfileParser(
1077
1077
* arrays are considered to be class types, they might
1078
1078
* appear as entries in 'newarray' or 'cast' opcodes.
1079
1079
*/
1080
- def getClassOrArrayType (index : Int )(implicit ctx : Context ): Type = {
1080
+ def getClassOrArrayType (index : Int )(using Context ): Type = {
1081
1081
if (index <= 0 || len <= index) errorBadIndex(index)
1082
1082
val value = values(index)
1083
1083
var c : Type = null
@@ -1102,15 +1102,15 @@ class ClassfileParser(
1102
1102
c
1103
1103
}
1104
1104
1105
- def getType (index : Int )(implicit ctx : Context ): Type =
1105
+ def getType (index : Int )(using Context ): Type =
1106
1106
sigToType(getExternalName(index))
1107
1107
1108
- def getSuperClass (index : Int )(implicit ctx : Context ): Symbol = {
1108
+ def getSuperClass (index : Int )(using Context ): Symbol = {
1109
1109
assert(index != 0 , " attempt to parse java.lang.Object from classfile" )
1110
1110
getClassSymbol(index)
1111
1111
}
1112
1112
1113
- def getConstant (index : Int , pt : Type = WildcardType )(implicit ctx : Context ): Constant = {
1113
+ def getConstant (index : Int , pt : Type = WildcardType )(using Context ): Constant = {
1114
1114
if (index <= 0 || len <= index) errorBadIndex(index)
1115
1115
var value = values(index)
1116
1116
if (value eq null ) {
0 commit comments