From aed2211149ef089eb9bb773cbd11fb5ac54a401c Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 1 Nov 2023 08:30:13 +0100 Subject: [PATCH] Update `_` wildcard type to `?` in compiler --- compiler/src/dotty/tools/backend/jvm/ClassfileWriters.scala | 2 +- compiler/src/dotty/tools/backend/jvm/CoreBTypes.scala | 2 +- .../src/dotty/tools/backend/jvm/DottyBackendInterface.scala | 2 +- .../dotty/tools/backend/jvm/GenericSignatureVisitor.scala | 2 +- compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala | 4 ++-- compiler/src/dotty/tools/backend/sjs/ScopedVar.scala | 2 +- compiler/src/dotty/tools/dotc/ast/TreeInfo.scala | 4 ++-- compiler/src/dotty/tools/dotc/ast/Trees.scala | 6 +++--- compiler/src/dotty/tools/dotc/inlines/Inliner.scala | 4 ++-- compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala | 2 +- compiler/src/dotty/tools/dotc/reporting/messages.scala | 2 +- compiler/src/dotty/tools/dotc/util/Stats.scala | 2 +- compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala | 2 +- compiler/test/dotty/tools/backend/jvm/AsmNode.scala | 2 +- .../test/dotty/tools/backend/jvm/DottyBytecodeTest.scala | 6 +++--- 15 files changed, 22 insertions(+), 22 deletions(-) diff --git a/compiler/src/dotty/tools/backend/jvm/ClassfileWriters.scala b/compiler/src/dotty/tools/backend/jvm/ClassfileWriters.scala index 928d19c92041..109fac06d63a 100644 --- a/compiler/src/dotty/tools/backend/jvm/ClassfileWriters.scala +++ b/compiler/src/dotty/tools/backend/jvm/ClassfileWriters.scala @@ -186,7 +186,7 @@ class ClassfileWriters(frontendAccess: PostProcessorFrontendAccess) { private final class DirEntryWriter(base: Path) extends FileWriter { val builtPaths = new ConcurrentHashMap[Path, java.lang.Boolean]() - val noAttributes = Array.empty[FileAttribute[_]] + val noAttributes = Array.empty[FileAttribute[?]] private val isWindows = scala.util.Properties.isWin private def checkName(component: Path): Unit = if (isWindows) { diff --git a/compiler/src/dotty/tools/backend/jvm/CoreBTypes.scala b/compiler/src/dotty/tools/backend/jvm/CoreBTypes.scala index 0e65850d4798..538c288b5ef6 100644 --- a/compiler/src/dotty/tools/backend/jvm/CoreBTypes.scala +++ b/compiler/src/dotty/tools/backend/jvm/CoreBTypes.scala @@ -138,7 +138,7 @@ abstract class CoreBTypesFromSymbols[I <: DottyBackendInterface] extends CoreBTy lazy val jlStringBuilderRef : ClassBType = synchClassBTypeFromSymbol(requiredClass[java.lang.StringBuilder]) lazy val jlStringBufferRef : ClassBType = synchClassBTypeFromSymbol(requiredClass[java.lang.StringBuffer]) lazy val jlCharSequenceRef : ClassBType = synchClassBTypeFromSymbol(requiredClass[java.lang.CharSequence]) - lazy val jlClassRef : ClassBType = synchClassBTypeFromSymbol(requiredClass[java.lang.Class[_]]) + lazy val jlClassRef : ClassBType = synchClassBTypeFromSymbol(requiredClass[java.lang.Class[?]]) lazy val jlThrowableRef : ClassBType = synchClassBTypeFromSymbol(defn.ThrowableClass) lazy val jlCloneableRef : ClassBType = synchClassBTypeFromSymbol(defn.JavaCloneableClass) lazy val jiSerializableRef : ClassBType = synchClassBTypeFromSymbol(requiredClass[java.io.Serializable]) diff --git a/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala b/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala index b2278c3f0ce8..c005a6d38403 100644 --- a/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala +++ b/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala @@ -93,7 +93,7 @@ class DottyBackendInterface(val superCallsMap: ReadOnlyMap[Symbol, Set[ClassSymb object DottyBackendInterface { - private def erasureString(clazz: Class[_]): String = { + private def erasureString(clazz: Class[?]): String = { if (clazz.isArray) "Array[" + erasureString(clazz.getComponentType) + "]" else clazz.getName } diff --git a/compiler/src/dotty/tools/backend/jvm/GenericSignatureVisitor.scala b/compiler/src/dotty/tools/backend/jvm/GenericSignatureVisitor.scala index c16bc70fc3b0..71bf307266c5 100644 --- a/compiler/src/dotty/tools/backend/jvm/GenericSignatureVisitor.scala +++ b/compiler/src/dotty/tools/backend/jvm/GenericSignatureVisitor.scala @@ -315,7 +315,7 @@ abstract class NestedClassesCollector[T](nestedOnly: Boolean) extends GenericSig if (annot.values != null) annot.values.asScala foreach visitConstant } - def visitAnnotations(annots: java.util.List[_ <: AnnotationNode]) = if (annots != null) annots.asScala foreach visitAnnotation + def visitAnnotations(annots: java.util.List[? <: AnnotationNode]) = if (annots != null) annots.asScala foreach visitAnnotation def visitAnnotationss(annotss: Array[java.util.List[AnnotationNode]]) = if (annotss != null) annotss foreach visitAnnotations def visitHandle(handle: Handle): Unit = { diff --git a/compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala b/compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala index 6edb15fb24a7..fa8f99fc0e03 100644 --- a/compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala +++ b/compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala @@ -1089,7 +1089,7 @@ class JSCodeGen()(using genCtx: Context) { val exports = List.newBuilder[jsExportsGen.Exported] val jsClassCaptures = List.newBuilder[js.ParamDef] - def add(tree: ConstructorTree[_ <: JSCtor]): Unit = { + def add(tree: ConstructorTree[? <: JSCtor]): Unit = { val (e, c) = genJSClassCtorDispatch(tree.ctor.sym, tree.ctor.paramsAndInfo, tree.overloadNum) exports += e @@ -1270,7 +1270,7 @@ class JSCodeGen()(using genCtx: Context) { * here we use the property from building the trees, that a set of * descendants always has a range of overload numbers. */ - def ifOverload(tree: ConstructorTree[_], body: js.Tree): js.Tree = body match { + def ifOverload(tree: ConstructorTree[?], body: js.Tree): js.Tree = body match { case js.Skip() => js.Skip() case body => diff --git a/compiler/src/dotty/tools/backend/sjs/ScopedVar.scala b/compiler/src/dotty/tools/backend/sjs/ScopedVar.scala index be5b8e7bb416..fd271685989c 100644 --- a/compiler/src/dotty/tools/backend/sjs/ScopedVar.scala +++ b/compiler/src/dotty/tools/backend/sjs/ScopedVar.scala @@ -28,7 +28,7 @@ object ScopedVar { implicit def toValue[T](scVar: ScopedVar[T]): T = scVar.get - def withScopedVars[T](ass: Assignment[_]*)(body: => T): T = { + def withScopedVars[T](ass: Assignment[?]*)(body: => T): T = { val stack = ass.map(_.push()) try body finally stack.reverse.foreach(_.pop()) diff --git a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala index 23dcfe392c27..7616ef220d7f 100644 --- a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala +++ b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala @@ -242,7 +242,7 @@ trait TreeInfo[T <: Untyped] { self: Trees.Instance[T] => /** Does this list contain a named argument tree? */ def hasNamedArg(args: List[Any]): Boolean = args exists isNamedArg - val isNamedArg: Any => Boolean = (arg: Any) => arg.isInstanceOf[Trees.NamedArg[_]] + val isNamedArg: Any => Boolean = (arg: Any) => arg.isInstanceOf[Trees.NamedArg[?]] /** Is this pattern node a catch-all (wildcard or variable) pattern? */ def isDefaultCase(cdef: CaseDef): Boolean = cdef match { @@ -1060,7 +1060,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] => def assertAllPositioned(tree: Tree)(using Context): Unit = tree.foreachSubTree { - case t: WithoutTypeOrPos[_] => + case t: WithoutTypeOrPos[?] => case t => assert(t.span.exists, i"$t") } diff --git a/compiler/src/dotty/tools/dotc/ast/Trees.scala b/compiler/src/dotty/tools/dotc/ast/Trees.scala index 6941596e1c9b..1ad8bf520830 100644 --- a/compiler/src/dotty/tools/dotc/ast/Trees.scala +++ b/compiler/src/dotty/tools/dotc/ast/Trees.scala @@ -31,7 +31,7 @@ object Trees { /** Property key for backquoted identifiers and definitions */ val Backquoted: Property.StickyKey[Unit] = Property.StickyKey() - + val SyntheticUnit: Property.StickyKey[Unit] = Property.StickyKey() /** Trees take a parameter indicating what the type of their `tpe` field @@ -932,11 +932,11 @@ object Trees { def rhs(using Context): Tree[T] = { forceFields(); preRhs.asInstanceOf[Tree[T]] } def leadingTypeParams(using Context): List[TypeDef[T]] = paramss match - case (tparams @ (tparam: TypeDef[_]) :: _) :: _ => tparams.asInstanceOf[List[TypeDef[T]]] + case (tparams @ (tparam: TypeDef[?]) :: _) :: _ => tparams.asInstanceOf[List[TypeDef[T]]] case _ => Nil def trailingParamss(using Context): List[ParamClause[T]] = paramss match - case ((tparam: TypeDef[_]) :: _) :: paramss1 => paramss1 + case ((tparam: TypeDef[?]) :: _) :: paramss1 => paramss1 case _ => paramss def termParamss(using Context): List[List[ValDef[T]]] = diff --git a/compiler/src/dotty/tools/dotc/inlines/Inliner.scala b/compiler/src/dotty/tools/dotc/inlines/Inliner.scala index b7bfdcf80e24..8d594448dc2a 100644 --- a/compiler/src/dotty/tools/dotc/inlines/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/inlines/Inliner.scala @@ -649,13 +649,13 @@ class Inliner(val call: tpd.Tree)(using Context): def treeSize(x: Any): Int = var siz = 0 x match - case x: Trees.Inlined[_] => + case x: Trees.Inlined[?] => case x: Positioned => var i = 0 while i < x.productArity do siz += treeSize(x.productElement(i)) i += 1 - case x: List[_] => + case x: List[?] => var xs = x while xs.nonEmpty do siz += treeSize(xs.head) diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index 3e6a8c66b1b1..60a25413d8e5 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -160,7 +160,7 @@ class PlainPrinter(_ctx: Context) extends Printer { core ~ cs.optionalInfo private def toTextRetainedElem[T <: Untyped](ref: Tree[T]): Text = ref match - case ref: RefTree[_] if ref.typeOpt.exists => + case ref: RefTree[?] if ref.typeOpt.exists => toTextCaptureRef(ref.typeOpt) case Apply(fn, Literal(str) :: Nil) if fn.symbol == defn.Caps_capIn => s"cap[${str.stringValue}]" diff --git a/compiler/src/dotty/tools/dotc/reporting/messages.scala b/compiler/src/dotty/tools/dotc/reporting/messages.scala index ae182ad211c0..3770d5f6f119 100644 --- a/compiler/src/dotty/tools/dotc/reporting/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/messages.scala @@ -2648,7 +2648,7 @@ class ExtensionCanOnlyHaveDefs(mdef: untpd.Tree)(using Context) |""" } -class UnexpectedPatternForSummonFrom(tree: Tree[_])(using Context) +class UnexpectedPatternForSummonFrom(tree: Tree[?])(using Context) extends SyntaxMsg(UnexpectedPatternForSummonFromID) { def msg(using Context) = i"Unexpected pattern for summonFrom. Expected ${hl("`x: T`")} or ${hl("`_`")}" def explain(using Context) = diff --git a/compiler/src/dotty/tools/dotc/util/Stats.scala b/compiler/src/dotty/tools/dotc/util/Stats.scala index 5157de832d3c..5e136856b718 100644 --- a/compiler/src/dotty/tools/dotc/util/Stats.scala +++ b/compiler/src/dotty/tools/dotc/util/Stats.scala @@ -32,7 +32,7 @@ import collection.mutable hits(name) += n } - def doRecordSize(fn: String, coll: scala.collection.Iterable[_]): coll.type = + def doRecordSize(fn: String, coll: scala.collection.Iterable[?]): coll.type = doRecord(fn, coll.size) coll diff --git a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala index f94aa12bd2d7..0f64d6e23b8e 100644 --- a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala +++ b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala @@ -1779,7 +1779,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler def show(using printer: Printer[TypeRepr]): String = printer.show(self) - def seal: scala.quoted.Type[_] = self.asType + def seal: scala.quoted.Type[?] = self.asType def asType: scala.quoted.Type[?] = new TypeImpl(Inferred(self), SpliceScope.getCurrent) diff --git a/compiler/test/dotty/tools/backend/jvm/AsmNode.scala b/compiler/test/dotty/tools/backend/jvm/AsmNode.scala index caaf250eeafa..046e93e0cfa2 100644 --- a/compiler/test/dotty/tools/backend/jvm/AsmNode.scala +++ b/compiler/test/dotty/tools/backend/jvm/AsmNode.scala @@ -28,7 +28,7 @@ sealed trait AsmNode[+T] { object AsmNode { type AsmMethod = AsmNode[MethodNode] type AsmField = AsmNode[FieldNode] - type AsmMember = AsmNode[_] + type AsmMember = AsmNode[?] implicit class ClassNodeOps(val node: ClassNode) { def fieldsAndMethods: List[AsmMember] = { diff --git a/compiler/test/dotty/tools/backend/jvm/DottyBytecodeTest.scala b/compiler/test/dotty/tools/backend/jvm/DottyBytecodeTest.scala index 6b7af09d4a2d..8a9611a9b165 100644 --- a/compiler/test/dotty/tools/backend/jvm/DottyBytecodeTest.scala +++ b/compiler/test/dotty/tools/backend/jvm/DottyBytecodeTest.scala @@ -202,7 +202,7 @@ trait DottyBytecodeTest { assert(succ, msg) } - private def sameCharacteristics(clazzA: ClassNode, clazzB: ClassNode)(f: AsmNode[_] => String): (Boolean, String) = { + private def sameCharacteristics(clazzA: ClassNode, clazzB: ClassNode)(f: AsmNode[?] => String): (Boolean, String) = { val ms1 = clazzA.fieldsAndMethods.toIndexedSeq val ms2 = clazzB.fieldsAndMethods.toIndexedSeq val name1 = clazzA.name @@ -254,7 +254,7 @@ trait DottyBytecodeTest { } .getOrElse(fail("Could not find constructor for object `Test`")) - private def boxingError(ins: List[_], source: String) = + private def boxingError(ins: List[?], source: String) = s"""|---------------------------------- |${ins.mkString("\n")} |---------------------------------- @@ -271,7 +271,7 @@ trait DottyBytecodeTest { } .getOrElse(fail("Could not find constructor for object `Test`")) - protected def boxingInstructions(method: MethodNode): (List[_], Boolean) = { + protected def boxingInstructions(method: MethodNode): (List[?], Boolean) = { val ins = instructionsFromMethod(method) val boxed = ins.exists { case Invoke(op, owner, name, desc, itf) =>