Skip to content

Commit 0c6b954

Browse files
Merge pull request lampepfl#28 from dotty-staging/fix-all-warinings
Fix all warnings
2 parents 9dfe905 + 31f9681 commit 0c6b954

File tree

10 files changed

+33
-60
lines changed

10 files changed

+33
-60
lines changed

src/compiler/scala/tools/nsc/backend/WorklistAlgorithm.scala

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,20 @@ import scala.collection.mutable
2323
*/
2424
trait WorklistAlgorithm {
2525
type Elem
26-
type WList = mutable.Stack[Elem]
26+
class WList {
27+
private[this] var list: List[Elem] = Nil
28+
def isEmpty = list.isEmpty
29+
def nonEmpty = !isEmpty
30+
def push(e: Elem): Unit = { list = e :: list }
31+
def pop(): Elem = {
32+
val head = list.head
33+
list = list.tail
34+
head
35+
}
36+
def pushAll(xs: Iterable[Elem]): Unit = xs.foreach(push)
37+
def clear(): Unit = list = Nil
38+
39+
}
2740

2841
val worklist: WList
2942

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ import interface._
7272
enclosingClass(classSym.originalOwner)
7373
}
7474

75-
final case class EnclosingMethodEntry(owner: String, name: String, methodDescriptor: String)
75+
/*final*/ case class EnclosingMethodEntry(owner: String, name: String, methodDescriptor: String)
7676

7777
/**
7878
* Data for emitting an EnclosingMethod attribute. None if `classSym` is a member class (not

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
478478
* Otherwise it's safe to call from multiple threads.
479479
*/
480480
def genConstant(const: Constant): Unit = {
481-
(const.tag: @switch) match {
481+
(const.tag/*: @switch*/) match {
482482

483483
case BooleanTag => bc.boolconst(const.booleanValue)
484484

@@ -625,7 +625,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
625625
for (i <- args.length until dims) elemKind = ArrayBType(elemKind)
626626
}
627627
genLoadArguments(args, List.fill(args.size)(INT))
628-
(argsSize : @switch) match {
628+
(argsSize /*: @switch*/) match {
629629
case 1 => bc newarray elemKind
630630
case _ =>
631631
val descr = ("[" * argsSize) + elemKind.descriptor // denotes the same as: arrayN(elemKind, argsSize).descriptor
@@ -871,7 +871,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
871871

872872
if(!int.shouldEmitJumpAfterLabels) genNormalBlock
873873
else {
874-
val (prefixLabels: List[LabelDef], stats1) = stats.span {
874+
val (prefixLabels: List[LabelDef] @unchecked, stats1) = stats.span {
875875
case t@LabelDef(_, _, _) => true
876876
case _ => false
877877
}
@@ -1221,7 +1221,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
12211221
if (tk.isIntSizedType) { // BOOL, BYTE, CHAR, SHORT, or INT
12221222
bc.emitIF(op, success)
12231223
} else if (tk.isRef) { // REFERENCE(_) | ARRAY(_)
1224-
op match { // references are only compared with EQ and NE
1224+
(op: @unchecked) match { // references are only compared with EQ and NE
12251225
case EQ => bc emitIFNULL success
12261226
case NE => bc emitIFNONNULL success
12271227
}
@@ -1415,7 +1415,8 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
14151415
new asm.Handle(invokeStyle,
14161416
classBTypeFromSymbol(lambdaTarget.owner).internalName,
14171417
lambdaTarget.name.mangledString,
1418-
asmMethodType(lambdaTarget).descriptor)
1418+
asmMethodType(lambdaTarget).descriptor,
1419+
invokeStyle == asm.Opcodes.H_INVOKEINTERFACE)
14191420

14201421
val (a,b) = lambdaTarget.info.paramTypes.splitAt(environmentSize)
14211422
var (capturedParamsTypes, lambdaParamTypes) = if(int.doLabmdasFollowJVMMetafactoryOrder) (a,b) else (b,a)
@@ -1445,6 +1446,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
14451446
val lambdaMetaFactoryBootstrapHandle =
14461447
new asm.Handle(asm.Opcodes.H_INVOKESTATIC,
14471448
int.LambdaMetaFactory.javaBinaryName, int.MetafactoryName,
1448-
"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;")
1449+
"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;",
1450+
false)
14491451

14501452
}

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

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -317,28 +317,11 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
317317

318318
trait BCForwardersGen extends BCAnnotGen with BCJGenSigGen {
319319

320-
/* Adds a @remote annotation, actual use unknown.
321-
*
322-
* Invoked from genMethod() and addForwarder().
323-
*
324-
* must-single-thread
325-
*/
326-
def addRemoteExceptionAnnot(isRemoteClass: Boolean, isJMethodPublic: Boolean, meth: Symbol): Unit = {
327-
val needsAnnotation = (
328-
( isRemoteClass ||
329-
isRemote(meth) && isJMethodPublic
330-
) && !(meth.throwsAnnotations contains RemoteExceptionClass)
331-
)
332-
if (needsAnnotation) {
333-
meth.addRemoteRemoteExceptionAnnotation
334-
}
335-
}
336-
337320
/* Add a forwarder for method m. Used only from addForwarders().
338321
*
339322
* must-single-thread
340323
*/
341-
private def addForwarder(isRemoteClass: Boolean, jclass: asm.ClassVisitor, module: Symbol, m: Symbol): Unit = {
324+
private def addForwarder(jclass: asm.ClassVisitor, module: Symbol, m: Symbol): Unit = {
342325
val moduleName = internalName(module)
343326
val methodInfo = module.thisType.memberInfo(m)
344327
val paramJavaTypes: List[BType] = methodInfo.paramTypes map toTypeKind
@@ -356,7 +339,6 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
356339

357340
// TODO needed? for(ann <- m.annotations) { ann.symbol.initialize }
358341
val jgensig = getStaticForwarderGenericSignature(m, module)
359-
addRemoteExceptionAnnot(isRemoteClass, hasPublicBitSet(flags), m)
360342
val (throws, others) = m.annotations partition (_.symbol == ThrowsClass)
361343
val thrownExceptions: List[String] = getExceptions(throws)
362344

@@ -400,14 +382,14 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
400382
*
401383
* must-single-thread
402384
*/
403-
def addForwarders(isRemoteClass: Boolean, jclass: asm.ClassVisitor, jclassName: String, moduleClass: Symbol): Unit = {
385+
def addForwarders(jclass: asm.ClassVisitor, jclassName: String, moduleClass: Symbol): Unit = {
404386
assert(moduleClass.isModuleClass, moduleClass)
405387
debuglog(s"Dumping mirror class for object: $moduleClass")
406388

407389
val linkedClass = moduleClass.companionClass
408390
lazy val conflictingNames: Set[Name] = {
409391
// Dotty deviation: needed to add ": Symbol" because of https://github.com/lampepfl/dotty/issues/2143
410-
(linkedClass.info.members collect { case sym: Symbol if sym.name.isTermName => sym.name }).toSet
392+
(linkedClass.info.members collect { case sym if sym.name.isTermName => sym.name }).toSet
411393
}
412394
debuglog(s"Potentially conflicting names for forwarders: $conflictingNames")
413395

@@ -420,7 +402,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
420402
log(s"No forwarder for non-public member $m")
421403
else {
422404
log(s"Adding static forwarder for '$m' from $jclassName to '$moduleClass'")
423-
addForwarder(isRemoteClass, jclass, moduleClass, m)
405+
addForwarder(jclass, moduleClass, m)
424406
}
425407
}
426408
}
@@ -515,7 +497,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
515497
mirrorClass.visitAttribute(if (ssa.isDefined) pickleMarkerLocal else pickleMarkerForeign)
516498
emitAnnotations(mirrorClass, moduleClass.annotations ++ ssa)
517499

518-
addForwarders(isRemote(moduleClass), mirrorClass, mirrorName, moduleClass)
500+
addForwarders(mirrorClass, mirrorName, moduleClass)
519501

520502
innerClassBufferASM ++= classBTypeFromSymbol(moduleClass).info.memberClasses
521503
addInnerClassesASM(mirrorClass, innerClassBufferASM.toList)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ trait BCodeIdiomatic {
415415
}
416416

417417
final def invokedynamic(owner: String, name: String, desc: String): Unit = {
418-
jmethod.visitMethodInsn(Opcodes.INVOKEDYNAMIC, owner, name, desc)
418+
jmethod.visitMethodInsn(Opcodes.INVOKEDYNAMIC, owner, name, desc, false)
419419
}
420420

421421
// can-multi-thread

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ trait BCodeSkelBuilder extends BCodeHelpers {
6666
var claszSymbol: Symbol = null
6767
var isCZParcelable = false
6868
var isCZStaticModule = false
69-
var isCZRemote = false
7069

7170
/* ---------------- idiomatic way to ask questions to typer ---------------- */
7271

@@ -94,7 +93,6 @@ trait BCodeSkelBuilder extends BCodeHelpers {
9493
claszSymbol = cd.symbol
9594
isCZParcelable = isAndroidParcelableClass(claszSymbol)
9695
isCZStaticModule = claszSymbol.isStaticModuleClass
97-
isCZRemote = isRemote(claszSymbol)
9896
thisName = internalName(claszSymbol)
9997

10098
cnode = new asm.tree.ClassNode()
@@ -175,7 +173,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
175173
val isCandidateForForwarders = lmoc.shouldEmitForwarders
176174
if (isCandidateForForwarders) {
177175
log(s"Adding static forwarders from '$claszSymbol' to implementations in '$lmoc'")
178-
addForwarders(isRemote(claszSymbol), cnode, thisName, lmoc.moduleClass)
176+
addForwarders(cnode, thisName, lmoc.moduleClass)
179177
}
180178
}
181179
}
@@ -519,7 +517,6 @@ trait BCodeSkelBuilder extends BCodeHelpers {
519517
def initJMethod(flags: Int, paramAnnotations: List[List[Annotation]]): Unit = {
520518

521519
val jgensig = getGenericSignature(methSymbol, claszSymbol)
522-
addRemoteExceptionAnnot(isCZRemote, hasPublicBitSet(flags), methSymbol)
523520
val (excs, others) = methSymbol.annotations partition (_.symbol == ThrowsClass)
524521
val thrownExceptions: List[String] = getExceptions(excs)
525522

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ abstract class BTypes {
738738
* Custom equals / hashCode: we only compare the name (offset / length)
739739
*/
740740
override def equals(o: Any): Boolean = (this eq o.asInstanceOf[Object]) || (o match {
741-
case c: ClassBType => c.internalName == this.internalName
741+
case c: ClassBType @unchecked => c.internalName == this.internalName
742742
case _ => false
743743
})
744744

@@ -859,5 +859,5 @@ abstract class BTypes {
859859
/**
860860
* Just a named pair, used in CoreBTypes.asmBoxTo/asmUnboxTo.
861861
*/
862-
final case class MethodNameAndType(name: String, methodType: MethodBType)
862+
/*final*/ case class MethodNameAndType(name: String, methodType: MethodBType)
863863
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ class BTypesFromSymbols[I <: BackendInterface](val int: I) extends BTypes {
180180
}
181181

182182
// legacy, to be removed when the @remote annotation gets removed
183-
final def isRemote(s: Symbol) = (s hasAnnotation RemoteAttr)
184183
final def hasPublicBitSet(flags: Int) = ((flags & asm.Opcodes.ACC_PUBLIC) != 0)
185184

186185
/**

src/compiler/scala/tools/nsc/backend/jvm/BackendInterface.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,8 +689,6 @@ abstract class BackendInterfaceDefinitions { self: BackendInterface =>
689689
// Class symbols used in backend.
690690
// Vals becouse they are to frequent in scala programs so that they are already loaded by backend
691691

692-
lazy val RemoteAttr: Symbol = requiredClass[scala.remote]
693-
lazy val BeanInfoAttr: Symbol = requiredClass[scala.beans.BeanInfo]
694692
lazy val NativeAttr: Symbol = requiredClass[scala.native]
695693
lazy val TransientAttr = requiredClass[scala.transient]
696694
lazy val VolatileAttr = requiredClass[scala.volatile]

src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -967,30 +967,13 @@ abstract class GenASM extends SubComponent with BytecodeWriters { self =>
967967
}
968968
}
969969

970-
/** Adds a @remote annotation, actual use unknown.
971-
*
972-
* Invoked from genMethod() and addForwarder().
973-
*/
974-
def addRemoteExceptionAnnot(isRemoteClass: Boolean, isJMethodPublic: Boolean, meth: Symbol) {
975-
val needsAnnotation = (
976-
( isRemoteClass ||
977-
isRemote(meth) && isJMethodPublic
978-
) && !(meth.throwsAnnotations contains RemoteExceptionClass)
979-
)
980-
if (needsAnnotation) {
981-
val c = Constant(RemoteExceptionClass.tpe)
982-
val arg = Literal(c) setType c.tpe
983-
meth.addAnnotation(appliedType(ThrowsClass, c.tpe), arg)
984-
}
985-
}
986-
987970
// -----------------------------------------------------------------------------------------
988971
// Static forwarders (related to mirror classes but also present in
989972
// a plain class lacking companion module, for details see `isCandidateForForwarders`).
990973
// -----------------------------------------------------------------------------------------
991974

992975
/** Add a forwarder for method m. Used only from addForwarders(). */
993-
private def addForwarder(isRemoteClass: Boolean, jclass: asm.ClassVisitor, module: Symbol, m: Symbol) {
976+
private def addForwarder(jclass: asm.ClassVisitor, module: Symbol, m: Symbol) {
994977
val moduleName = javaName(module)
995978
val methodInfo = module.thisType.memberInfo(m)
996979
val paramJavaTypes: List[asm.Type] = methodInfo.paramTypes map javaType
@@ -1008,7 +991,6 @@ abstract class GenASM extends SubComponent with BytecodeWriters { self =>
1008991

1009992
// TODO needed? for(ann <- m.annotations) { ann.symbol.initialize }
1010993
val jgensig = staticForwarderGenericSignature(m, module)
1011-
addRemoteExceptionAnnot(isRemoteClass, hasPublicBitSet(flags), m)
1012994
val (throws, others) = m.annotations partition (_.symbol == ThrowsClass)
1013995
val thrownExceptions: List[String] = getExceptions(throws)
1014996

0 commit comments

Comments
 (0)