Skip to content

Commit 2cd2472

Browse files
committed
Remove warnings in rest of compiler codebase
Still todo: remove warnings in shaded modules
1 parent 3b5c510 commit 2cd2472

Some content is hidden

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

56 files changed

+347
-346
lines changed

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

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,11 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
155155
stack.pop()
156156

157157
(code: @switch) match {
158-
case ADD => bc add resKind
159-
case SUB => bc sub resKind
160-
case MUL => bc mul resKind
161-
case DIV => bc div resKind
162-
case MOD => bc rem resKind
158+
case ADD => bc.add(resKind)
159+
case SUB => bc.sub(resKind)
160+
case MUL => bc.mul(resKind)
161+
case DIV => bc.div(resKind)
162+
case MOD => bc.rem(resKind)
163163

164164
case OR | XOR | AND => bc.genPrimitiveLogical(code, resKind)
165165

@@ -271,11 +271,11 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
271271
genCond(tree, success, failure, targetIfNoJump = success)
272272
// success block
273273
markProgramPoint(success)
274-
bc boolconst true
275-
bc goTo after
274+
bc.boolconst(true)
275+
bc.goTo(after)
276276
// failure block
277277
markProgramPoint(failure)
278-
bc boolconst false
278+
bc.boolconst(false)
279279
// after
280280
markProgramPoint(after)
281281

@@ -501,16 +501,16 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
501501
val stackDiff = stack.heightDiffWrt(targetStackSize)
502502
if stackDiff != 0 then
503503
if expectedType == UNIT then
504-
bc dropMany stackDiff
504+
bc.dropMany(stackDiff)
505505
else
506506
val loc = locals.makeTempLocal(expectedType)
507507
bc.store(loc.idx, expectedType)
508-
bc dropMany stackDiff
508+
bc.dropMany(stackDiff)
509509
bc.load(loc.idx, expectedType)
510510
end if
511-
bc goTo label
511+
bc.goTo(label)
512512
case LoadDestination.Return =>
513-
bc emitRETURN returnType
513+
bc.emitRETURN(returnType)
514514
case LoadDestination.Throw =>
515515
val thrownType = expectedType
516516
// `throw null` is valid although scala.Null (as defined in src/libray-aux) isn't a subtype of Throwable.
@@ -634,7 +634,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
634634
}
635635
locals.store(earlyReturnVar)
636636
}
637-
bc goTo nextCleanup
637+
bc.goTo(nextCleanup)
638638
shouldEmitCleanup = true
639639
}
640640
} else {
@@ -697,20 +697,20 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
697697
if (l.isPrimitive && r.isPrimitive)
698698
genConversion(l, r, cast)
699699
else if (l.isPrimitive) {
700-
bc drop l
700+
bc.drop(l)
701701
if (cast) {
702702
mnode.visitTypeInsn(asm.Opcodes.NEW, jlClassCastExceptionRef.internalName)
703-
bc dup ObjectRef
703+
bc.dup(ObjectRef)
704704
emit(asm.Opcodes.ATHROW)
705705
} else {
706-
bc boolconst false
706+
bc.boolconst(false)
707707
}
708708
}
709709
else if (r.isPrimitive && cast) {
710710
abort(s"Erasure should have added an unboxing operation to prevent this cast. Tree: $t")
711711
}
712712
else if (r.isPrimitive) {
713-
bc isInstance boxedClassOfPrimitive(r.asPrimitiveBType)
713+
bc.isInstance(boxedClassOfPrimitive(r.asPrimitiveBType))
714714
}
715715
else {
716716
assert(r.isRef, r) // ensure that it's not a method
@@ -737,7 +737,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
737737
}
738738
genLoadArguments(args, List.fill(args.size)(INT))
739739
(argsSize /*: @switch*/) match {
740-
case 1 => bc newarray elemKind
740+
case 1 => bc.newarray(elemKind)
741741
case _ =>
742742
val descr = ("[" * argsSize) + elemKind.descriptor // denotes the same as: arrayN(elemKind, argsSize).descriptor
743743
mnode.visitMultiANewArrayInsn(descr, argsSize)
@@ -792,7 +792,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
792792
case rt: ClassBType =>
793793
assert(classBTypeFromSymbol(ctor.owner) == rt, s"Symbol ${ctor.owner.showFullName} is different from $rt")
794794
mnode.visitTypeInsn(asm.Opcodes.NEW, rt.internalName)
795-
bc dup generatedType
795+
bc.dup(generatedType)
796796
stack.push(rt)
797797
stack.push(rt)
798798
genLoadArguments(args, paramTKs(app))
@@ -888,8 +888,8 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
888888
val elmKind = toTypeKind(elemType)
889889
val generatedType = ArrayBType(elmKind)
890890

891-
bc iconst elems.length
892-
bc newarray elmKind
891+
bc.iconst(elems.length)
892+
bc.newarray(elmKind)
893893

894894
// during the genLoad below, there is the result, its dup, and the index
895895
stack.push(generatedType)
@@ -899,10 +899,10 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
899899
var i = 0
900900
var rest = elems
901901
while (!rest.isEmpty) {
902-
bc dup generatedType
903-
bc iconst i
902+
bc.dup( generatedType)
903+
bc.iconst( i)
904904
genLoad(rest.head, elmKind)
905-
bc astore elmKind
905+
bc.astore( elmKind)
906906
rest = rest.tail
907907
i = i + 1
908908
}
@@ -1070,7 +1070,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
10701070
}
10711071
markProgramPoint(keepGoing)
10721072
}
1073-
bc goTo default
1073+
bc.goTo(default)
10741074
}
10751075

10761076
// emit blocks for common patterns
@@ -1111,7 +1111,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
11111111
def adapt(from: BType, to: BType): Unit = {
11121112
if (!from.conformsTo(to)) {
11131113
to match {
1114-
case UNIT => bc drop from
1114+
case UNIT => bc.drop(from)
11151115
case _ => bc.emitT2T(from, to)
11161116
}
11171117
} else if (from.isNothingType) {
@@ -1174,7 +1174,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
11741174
* inserted instead - after all, an expression of type scala.runtime.Null$ can only be null.
11751175
*/
11761176
if (lastInsn.getOpcode != asm.Opcodes.ACONST_NULL) {
1177-
bc drop from
1177+
bc.drop(from)
11781178
emit(asm.Opcodes.ACONST_NULL)
11791179
}
11801180
}
@@ -1248,14 +1248,14 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
12481248
def genConversion(from: BType, to: BType, cast: Boolean): Unit = {
12491249
if (cast) { bc.emitT2T(from, to) }
12501250
else {
1251-
bc drop from
1252-
bc boolconst (from == to)
1251+
bc.drop(from)
1252+
bc.boolconst(from == to)
12531253
}
12541254
}
12551255

12561256
def genCast(to: RefBType, cast: Boolean): Unit = {
1257-
if (cast) { bc checkCast to }
1258-
else { bc isInstance to }
1257+
if cast then bc.checkCast(to)
1258+
else bc.isInstance(to)
12591259
}
12601260

12611261
/* Is the given symbol a primitive operation? */
@@ -1504,7 +1504,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
15041504
}
15051505
bc.emitIF(op, success)
15061506
}
1507-
if (targetIfNoJump != failure) bc goTo failure
1507+
if (targetIfNoJump != failure) bc.goTo(failure)
15081508
}
15091509
}
15101510

@@ -1517,8 +1517,8 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
15171517
bc.emitIF(op, success)
15181518
} else if (tk.isRef) { // REFERENCE(_) | ARRAY(_)
15191519
(op: @unchecked) match { // references are only compared with EQ and NE
1520-
case EQ => bc emitIFNULL success
1521-
case NE => bc emitIFNONNULL success
1520+
case EQ => bc.emitIFNULL( success)
1521+
case NE => bc.emitIFNONNULL(success)
15221522
}
15231523
} else {
15241524
def useCmpG = if (negated) op == GT || op == GE else op == LT || op == LE
@@ -1535,7 +1535,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
15351535
}
15361536
bc.emitIF(op, success)
15371537
}
1538-
if (targetIfNoJump != failure) bc goTo failure
1538+
if (targetIfNoJump != failure) bc.goTo(failure)
15391539
}
15401540
}
15411541

@@ -1663,12 +1663,12 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
16631663
val areSameFinals = l.tpe.typeSymbol.is(Final) && r.tpe.typeSymbol.is(Final) && (l.tpe =:= r.tpe)
16641664
// todo: remove
16651665
def isMaybeBoxed(sym: Symbol): Boolean = {
1666-
(sym == defn.ObjectClass) ||
1667-
(sym == defn.JavaSerializableClass) ||
1668-
(sym == defn.ComparableClass) ||
1669-
(sym derivesFrom defn.BoxedNumberClass) ||
1670-
(sym derivesFrom defn.BoxedCharClass) ||
1671-
(sym derivesFrom defn.BoxedBooleanClass)
1666+
sym == defn.ObjectClass
1667+
|| sym == defn.JavaSerializableClass
1668+
|| sym == defn.ComparableClass
1669+
|| sym.derivesFrom(defn.BoxedNumberClass)
1670+
|| sym.derivesFrom(defn.BoxedCharClass)
1671+
|| sym.derivesFrom(defn.BoxedBooleanClass)
16721672
}
16731673
!areSameFinals && isMaybeBoxed(l.tpe.typeSymbol) && isMaybeBoxed(r.tpe.typeSymbol)
16741674
}
@@ -1722,11 +1722,11 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
17221722
genLoad(r, ObjectRef)
17231723
stack.pop()
17241724
locals.store(eqEqTempLocal)
1725-
bc dup ObjectRef
1725+
bc.dup(ObjectRef)
17261726
genCZJUMP(lNull, lNonNull, Primitives.EQ, ObjectRef, targetIfNoJump = lNull)
17271727

17281728
markProgramPoint(lNull)
1729-
bc drop ObjectRef
1729+
bc.drop(ObjectRef)
17301730
locals.load(eqEqTempLocal)
17311731
genCZJUMP(success, failure, Primitives.EQ, ObjectRef, targetIfNoJump = lNonNull)
17321732

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ trait BCodeHelpers extends BCodeIdiomatic {
107107
val versionPickle = {
108108
val vp = new PickleBuffer(new Array[Byte](16), -1, 0)
109109
assert(vp.writeIndex == 0, vp)
110-
vp writeNat PickleFormat.MajorVersion
111-
vp writeNat PickleFormat.MinorVersion
112-
vp writeNat 0
110+
vp.writeNat(PickleFormat.MajorVersion)
111+
vp.writeNat(PickleFormat.MinorVersion)
112+
vp.writeNat(0)
113113
vp
114114
}
115115

@@ -531,7 +531,7 @@ trait BCodeHelpers extends BCodeIdiomatic {
531531
val buffer = mutable.ListBuffer[Symbol]()
532532
names.foreach { name =>
533533
buffer ++= tp.memberBasedOnFlags(name, required, excluded)
534-
.alternatives.sortBy(_.signature)(Signature.lexicographicOrdering).map(_.symbol)
534+
.alternatives.sortBy(_.signature)(using Signature.lexicographicOrdering).map(_.symbol)
535535
}
536536
buffer.toList
537537
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,13 +598,13 @@ trait BCodeSkelBuilder extends BCodeHelpers {
598598
case labnode: asm.tree.LabelNode => labnode.getLabel
599599
case _ =>
600600
val pp = new asm.Label
601-
mnode visitLabel pp
601+
mnode.visitLabel(pp)
602602
pp
603603
}
604604
}
605605
def markProgramPoint(lbl: asm.Label): Unit = {
606606
val skip = (lbl == null) || isAtProgramPoint(lbl)
607-
if (!skip) { mnode visitLabel lbl }
607+
if (!skip) { mnode.visitLabel(lbl) }
608608
}
609609
def isAtProgramPoint(lbl: asm.Label): Boolean = {
610610
def getNonLineNumberNode(a: asm.tree.AbstractInsnNode): asm.tree.AbstractInsnNode = a match {

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ trait BCodeSyncAndTry extends BCodeBodyBuilder {
4040

4141
/* ------ (1) pushing and entering the monitor, also keeping a reference to it in a local var. ------ */
4242
genLoadQualifier(fun)
43-
bc dup ObjectRef
43+
bc.dup(ObjectRef)
4444
locals.store(monitor)
4545
emit(asm.Opcodes.MONITORENTER)
4646

@@ -68,7 +68,7 @@ trait BCodeSyncAndTry extends BCodeBodyBuilder {
6868
emit(asm.Opcodes.MONITOREXIT)
6969
if (hasResult) { locals.load(monitorResult) }
7070
val postHandler = new asm.Label
71-
bc goTo postHandler
71+
bc.goTo(postHandler)
7272

7373
/* ------ (4) exception-handler version of monitor-exit code.
7474
* Reached upon abrupt termination of (2).
@@ -99,7 +99,7 @@ trait BCodeSyncAndTry extends BCodeBodyBuilder {
9999
* Protected by whatever protects the whole synchronized expression.
100100
* ------
101101
*/
102-
mnode visitLabel postHandler
102+
mnode.visitLabel(postHandler)
103103

104104
lineNumber(tree)
105105

@@ -258,7 +258,7 @@ trait BCodeSyncAndTry extends BCodeBodyBuilder {
258258
unregisterCleanup(finCleanup)
259259
nopIfNeeded(startTryBody)
260260
val endTryBody = currProgramPoint()
261-
bc goTo postHandlers
261+
bc.goTo(postHandlers)
262262

263263
/**
264264
* A return within a `try` or `catch` block where a `finally` is present ("early return")
@@ -305,7 +305,7 @@ trait BCodeSyncAndTry extends BCodeBodyBuilder {
305305
registerCleanup(finCleanup)
306306
ch match {
307307
case NamelessEH(typeToDrop, caseBody) =>
308-
bc drop typeToDrop
308+
bc.drop(typeToDrop)
309309
genLoad(caseBody, kind) // adapts caseBody to `kind`, thus it can be stored, if `guardResult`, in `tmp`.
310310
nopIfNeeded(startHandler)
311311
endHandler = currProgramPoint()
@@ -326,7 +326,7 @@ trait BCodeSyncAndTry extends BCodeBodyBuilder {
326326
// (2.b) mark the try-body as protected by this case clause.
327327
protect(startTryBody, endTryBody, startHandler, excType)
328328
// (2.c) emit jump to the program point where the finally-clause-for-normal-exit starts, or in effect `after` if no finally-clause was given.
329-
bc goTo postHandlers
329+
bc.goTo(postHandlers)
330330

331331
}
332332

@@ -434,12 +434,12 @@ trait BCodeSyncAndTry extends BCodeBodyBuilder {
434434
locals.load(earlyReturnVar)
435435
bc.emitRETURN(locals(earlyReturnVar).tk)
436436
} else {
437-
bc emitRETURN UNIT
437+
bc.emitRETURN(UNIT)
438438
}
439439
shouldEmitCleanup = false
440440

441441
case nextCleanup :: _ =>
442-
bc goTo nextCleanup
442+
bc.goTo(nextCleanup)
443443
}
444444
}
445445

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class BackendUtils(val postProcessor: PostProcessor) {
155155
*/
156156
final def addInnerClasses(jclass: asm.ClassVisitor, declaredInnerClasses: List[ClassBType], refedInnerClasses: List[ClassBType]): Unit = {
157157
// sorting ensures nested classes are listed after their enclosing class thus satisfying the Eclipse Java compiler
158-
val allNestedClasses = new mutable.TreeSet[ClassBType]()(Ordering.by(_.internalName))
158+
val allNestedClasses = new mutable.TreeSet[ClassBType]()(using Ordering.by(_.internalName))
159159
allNestedClasses ++= declaredInnerClasses
160160
refedInnerClasses.foreach(allNestedClasses ++= _.enclosingNestedClassesChain)
161161
for nestedClass <- allNestedClasses

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,9 @@ class ClassfileWriters(frontendAccess: PostProcessorFrontendAccess) {
272272
else throw new FileConflictException(s"${base.path}/${path}: ${dir.path} is not a directory")
273273
val components = path.split('/')
274274
var dir = base
275-
for (i <- 0 until components.length - 1) dir = ensureDirectory(dir) subdirectoryNamed components(i).toString
276-
ensureDirectory(dir) fileNamed components.last.toString
275+
for i <- 0 until components.length - 1 do
276+
dir = ensureDirectory(dir).subdirectoryNamed(components(i).toString)
277+
ensureDirectory(dir).fileNamed(components.last.toString)
277278
}
278279

279280
private def writeBytes(outFile: AbstractFile, bytes: Array[Byte]): Unit = {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class DottyPrimitives(ictx: Context) {
127127

128128
/** Add a primitive operation to the map */
129129
def addPrimitive(s: Symbol, code: Int): Unit = {
130-
assert(!(primitives contains s), "Duplicate primitive " + s)
130+
assert(!primitives.contains(s), "Duplicate primitive " + s)
131131
primitives(s) = code
132132
}
133133

0 commit comments

Comments
 (0)