Skip to content

Change colon to with in dotty codebase #11199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.junit.{Ignore, Test}
import org.junit.Assert.{assertEquals, fail}
import org.junit.experimental.categories.Category

abstract class CommunityBuildTest:
abstract class CommunityBuildTest with
given CommunityBuildTest = this

/** Depending on the mode of operation, either
Expand Down Expand Up @@ -81,7 +81,7 @@ abstract class CommunityBuildTest:
end CommunityBuildTest

@Category(Array(classOf[TestCategory]))
class CommunityBuildTestA extends CommunityBuildTest:
class CommunityBuildTestA extends CommunityBuildTest with
@Test def endpoints4s = projects.endpoints4s.run()
@Test def fansi = projects.fansi.run()
@Test def fastparse = projects.fastparse.run()
Expand Down Expand Up @@ -119,7 +119,7 @@ class CommunityBuildTestA extends CommunityBuildTest:
end CommunityBuildTestA

@Category(Array(classOf[TestCategory]))
class CommunityBuildTestB extends CommunityBuildTest:
class CommunityBuildTestB extends CommunityBuildTest with
@Test def algebra = projects.algebra.run()
@Test def betterfiles = projects.betterfiles.run()
@Test def cats = projects.cats.run()
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/Bench.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import scala.annotation.internal.sharable
* number of compilers and run each (sequentially) a given number of times
* on the same sources.
*/
object Bench extends Driver:
object Bench extends Driver with

@sharable private var numRuns = 1

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ object DesugarEnums {
val Simple, Object, Class: Value = Value
}

final case class EnumConstraints(minKind: CaseKind.Value, maxKind: CaseKind.Value, enumCases: List[(Int, RefTree)]):
final case class EnumConstraints(minKind: CaseKind.Value, maxKind: CaseKind.Value, enumCases: List[(Int, RefTree)]) with
require(minKind <= maxKind && !(cached && enumCases.isEmpty))
def requiresCreator = minKind == CaseKind.Simple
def isEnumeration = maxKind < CaseKind.Class
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
/** Extractor for not-null assertions.
* A not-null assertion for reference `x` has the form `x.$asInstanceOf$[x.type & T]`.
*/
object AssertNotNull :
object AssertNotNull with
def apply(tree: tpd.Tree, tpnn: Type)(using Context): tpd.Tree =
tree.select(defn.Any_typeCast).appliedToType(AndType(tree.tpe, tpnn))

Expand Down
8 changes: 4 additions & 4 deletions compiler/src/dotty/tools/dotc/ast/Trees.scala
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ object Trees {
def rhs(using Context): Tree[T] = forceIfLazy
}

trait ValOrTypeDef[-T >: Untyped] extends MemberDef[T]:
trait ValOrTypeDef[-T >: Untyped] extends MemberDef[T] with
type ThisTree[-T >: Untyped] <: ValOrTypeDef[T]

type ParamClause[T >: Untyped] = List[ValDef[T]] | List[TypeDef[T]]
Expand Down Expand Up @@ -444,7 +444,7 @@ object Trees {
}

/** The kind of application */
enum ApplyKind:
enum ApplyKind with
case Regular // r.f(x)
case Using // r.f(using x)
case InfixTuple // r f (x1, ..., xN) where N != 1; needs to be treated specially for an error message in typedApply
Expand Down Expand Up @@ -1591,12 +1591,12 @@ object Trees {
}
}.asInstanceOf[tree.ThisTree[T]]

object TypeDefs:
object TypeDefs with
def unapply(xs: List[Tree]): Option[List[TypeDef]] = xs match
case (x: TypeDef) :: _ => Some(xs.asInstanceOf[List[TypeDef]])
case _ => None

object ValDefs:
object ValDefs with
def unapply(xs: List[Tree]): Option[List[ValDef]] = xs match
case Nil => Some(Nil)
case (x: ValDef) :: _ => Some(xs.asInstanceOf[List[ValDef]])
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/ast/tpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1230,12 +1230,12 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
Ident(defn.ScalaRuntimeModule.requiredMethod(name).termRef).appliedToTermArgs(args)

/** An extractor that pulls out type arguments */
object MaybePoly:
object MaybePoly with
def unapply(tree: Tree): Option[(Tree, List[Tree])] = tree match
case TypeApply(tree, targs) => Some(tree, targs)
case _ => Some(tree, Nil)

object TypeArgs:
object TypeArgs with
def unapply(ts: List[Tree]): Option[List[Tree]] =
if ts.nonEmpty && ts.head.isType then Some(ts) else None

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/untpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
}

def WildcardTypeBoundsTree()(using src: SourceFile): TypeBoundsTree = TypeBoundsTree(EmptyTree, EmptyTree, EmptyTree)
object WildcardTypeBoundsTree:
object WildcardTypeBoundsTree with
def unapply(tree: untpd.Tree): Boolean = tree match
case TypeBoundsTree(EmptyTree, EmptyTree, _) => true
case _ => false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import java.lang.Character.isWhitespace

/** A simple enough command line parser.
*/
object CommandLineParser:
object CommandLineParser with
inline private val DQ = '"'
inline private val SQ = '\''
inline private val EOF = -1
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/Feature.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import util.SrcPos
import SourceVersion._
import reporting.Message

object Feature:
object Feature with

private val dependent = "dependent".toTermName
private val namedTypeArguments = "namedTypeArguments".toTermName
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/config/SourceVersion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import core.StdNames.nme
import core.Decorators.{_, given}
import util.Property

enum SourceVersion:
enum SourceVersion with
case `3.0-migration`, `3.0`, `3.1-migration`, `3.1`

val isMigrating: Boolean = toString.endsWith("-migration")
Expand All @@ -18,7 +18,7 @@ enum SourceVersion:

def isAtLeast(v: SourceVersion) = stable.ordinal >= v.ordinal

object SourceVersion extends Property.Key[SourceVersion]:
object SourceVersion extends Property.Key[SourceVersion] with
def defaultSourceVersion = `3.0`

val allSourceVersionNames = values.toList.map(_.toString.toTermName)
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Atoms.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Types._
* If the underlying type of a singleton type is another singleton type,
* only the latter type ends up in the sets.
*/
enum Atoms:
enum Atoms with
case Range(lo: Set[Type], hi: Set[Type])
case Unknown

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ trait ConstraintHandling {
/** Substitute wildcards with fresh TypeParamRefs, to be compared with
* other bound, so that they can be instantiated.
*/
object substWildcards extends TypeMap:
object substWildcards extends TypeMap with
override def stopAtStatic = true

var trackedPolis: List[PolyType] = Nil
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/ContextOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import SymDenotations.LazyType, Names.Name, StdNames.nme
import ast.untpd

/** Extension methods for contexts where we want to keep the ctx.<methodName> syntax */
object ContextOps:
object ContextOps with

extension (ctx: Context)

Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ class Definitions {

@tu lazy val TupleType: Array[TypeRef] = mkArityArray("scala.Tuple", MaxTupleArity, 1)

private class FunType(prefix: String):
private class FunType(prefix: String) with
private var classRefs: Array[TypeRef] = new Array(22)
def apply(n: Int): TypeRef =
while n >= classRefs.length do
Expand Down Expand Up @@ -1526,7 +1526,7 @@ class Definitions {
* dependent refinements. Optionally returns a triple consisting of the argument
* types `As`, the result type `B` and a whether the type is an erased context function.
*/
object ContextFunctionType:
object ContextFunctionType with
def unapply(tp: Type)(using Context): Option[(List[Type], Type, Boolean)] =
if ctx.erasedTypes then
atPhase(erasurePhase)(unapply(tp))
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/core/NamerOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import config.Config
import ast.untpd

/** Operations that are shared between Namer and TreeUnpickler */
object NamerOps:
object NamerOps with

/** The given type, unless `sym` is a constructor, in which case the
* type of the constructed instance is returned
Expand Down Expand Up @@ -83,7 +83,7 @@ object NamerOps:
&& !cls.isAnonymousClass

/** The completer of a constructor proxy apply method */
class ApplyProxyCompleter(constr: Symbol)(using Context) extends LazyType:
class ApplyProxyCompleter(constr: Symbol)(using Context) extends LazyType with
def complete(denot: SymDenotation)(using Context): Unit =
denot.info = constr.info

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Names.scala
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ object Names {
chrs.copyToArray(newchrs)
chrs = newchrs

private class NameTable extends HashSet[SimpleName](initialCapacity = 0x10000, capacityMultiple = 2):
private class NameTable extends HashSet[SimpleName](initialCapacity = 0x10000, capacityMultiple = 2) with
import util.Stats

override def hash(x: SimpleName) = hashValue(chrs, x.start, x.length) // needed for resize
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Substituters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Types._, Symbols._, Contexts._, Decorators._
/** Substitution operations on types. See the corresponding `subst` and
* `substThis` methods on class Type for an explanation.
*/
object Substituters:
object Substituters with

final def subst(tp: Type, from: BindingType, to: BindingType, theMap: SubstBindingMap)(using Context): Type =
tp match {
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2556,7 +2556,7 @@ object SymDenotations {
def needsCompletion(symd: SymDenotation)(using Context): Boolean = true
}

object LazyType:
object LazyType with
private val NoSymbolFn = (_: Context) ?=> NoSymbol

/** A subtrait of LazyTypes where completerTypeParams yields a List[TypeSymbol], which
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -864,15 +864,15 @@ object Symbols {
/** Matches lists of term symbols, including the empty list.
* All symbols in the list are assumed to be of the same kind.
*/
object TermSymbols:
object TermSymbols with
def unapply(xs: List[Symbol])(using Context): Option[List[TermSymbol]] = xs match
case (x: Symbol) :: _ if x.isType => None
case _ => Some(xs.asInstanceOf[List[TermSymbol]])

/** Matches lists of type symbols, excluding the empty list.
* All symbols in the list are assumed to be of the same kind.
*/
object TypeSymbols:
object TypeSymbols with
def unapply(xs: List[Symbol])(using Context): Option[List[TypeSymbol]] = xs match
case (x: Symbol) :: _ if x.isType => Some(xs.asInstanceOf[List[TypeSymbol]])
case _ => None
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/TypeApplications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ object TypeApplications {
*
* @param tycon C
*/
object EtaExpansion:
object EtaExpansion with

def apply(tycon: Type)(using Context): Type =
assert(tycon.typeParams.nonEmpty, tycon)
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2558,7 +2558,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling

object TypeComparer {

enum CompareResult:
enum CompareResult with
case OK, Fail, OKwithGADTUsed

/** Class for unification variables used in `natValue`. */
Expand All @@ -2577,7 +2577,7 @@ object TypeComparer {
* - `LoApprox`: The left type is approximated (i.e widened)"
* - `HiApprox`: The right type is approximated (i.e narrowed)"
*/
object ApproxState:
object ApproxState with
opaque type Repr = Int

val None: Repr = 0
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/TypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import reporting.TestingReporter
import scala.annotation.internal.sharable
import scala.annotation.threadUnsafe

object TypeOps:
object TypeOps with

@sharable var track: Boolean = false // for debugging

Expand Down
14 changes: 7 additions & 7 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ object Types {
def isProvisional(using Context): Boolean = mightBeProvisional && testProvisional

private def testProvisional(using Context): Boolean =
class ProAcc extends TypeAccumulator[Boolean]:
class ProAcc extends TypeAccumulator[Boolean] with
override def apply(x: Boolean, t: Type) = x || test(t, this)
def test(t: Type, theAcc: TypeAccumulator[Boolean]): Boolean =
if t.mightBeProvisional then
Expand Down Expand Up @@ -3413,7 +3413,7 @@ object Types {
private var myParamDependencyStatus: DependencyStatus = Unknown

private def depStatus(initial: DependencyStatus, tp: Type)(using Context): DependencyStatus =
class DepAcc extends TypeAccumulator[DependencyStatus]:
class DepAcc extends TypeAccumulator[DependencyStatus] with
def apply(status: DependencyStatus, tp: Type) = compute(status, tp, this)
def combine(x: DependencyStatus, y: DependencyStatus) =
val status = (x & StatusMask) max (y & StatusMask)
Expand Down Expand Up @@ -4419,7 +4419,7 @@ object Types {
s"TypeVar($origin$instStr)"
}
}
object TypeVar:
object TypeVar with
def apply(initOrigin: TypeParamRef, creatorState: TyperState)(using Context) =
new TypeVar(initOrigin, creatorState, ctx.owner.nestingLevel)

Expand Down Expand Up @@ -4841,7 +4841,7 @@ object Types {

class CachedAnnotatedType(parent: Type, annot: Annotation) extends AnnotatedType(parent, annot)

object AnnotatedType:
object AnnotatedType with
def make(underlying: Type, annots: List[Annotation])(using Context): Type =
annots.foldLeft(underlying)(apply(_, _))
def apply(parent: Type, annot: Annotation)(using Context): AnnotatedType =
Expand Down Expand Up @@ -4889,14 +4889,14 @@ object Types {
def msg(using Context): Message
}

object ErrorType:
object ErrorType with
def apply(m: Message)(using Context): ErrorType =
val et = new PreviousErrorType
ctx.base.errorTypeMsg(et) = m
et
end ErrorType

class PreviousErrorType extends ErrorType:
class PreviousErrorType extends ErrorType with
def msg(using Context): Message =
ctx.base.errorTypeMsg.get(this) match
case Some(m) => m
Expand Down Expand Up @@ -5053,7 +5053,7 @@ object Types {
// ----- TypeMaps --------------------------------------------------------------------

/** Common base class of TypeMap and TypeAccumulator */
abstract class VariantTraversal:
abstract class VariantTraversal with
protected[core] var variance: Int = 1

inline protected def atVariance[T](v: Int)(op: => T): T = {
Expand Down
8 changes: 4 additions & 4 deletions compiler/src/dotty/tools/dotc/core/Uniques.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import config.Config
import Decorators._
import util.{HashSet, Stats}

class Uniques extends HashSet[Type](Config.initialUniquesCapacity):
class Uniques extends HashSet[Type](Config.initialUniquesCapacity) with
override def hash(x: Type): Int = x.hash
override def isEqual(x: Type, y: Type) = x.eql(y)

Expand All @@ -15,7 +15,7 @@ class Uniques extends HashSet[Type](Config.initialUniquesCapacity):
* All sets offer a `enterIfNew` method which checks whether a type
* with the given parts exists already and creates a new one if not.
*/
object Uniques:
object Uniques with

private inline def recordCaching(tp: Type): Unit = recordCaching(tp.hash, tp.getClass)
private inline def recordCaching(h: Int, clazz: Class[?]): Unit =
Expand All @@ -32,7 +32,7 @@ object Uniques:
if tp.hash == NotCached then tp
else ctx.uniques.put(tp).asInstanceOf[T]

final class NamedTypeUniques extends HashSet[NamedType](Config.initialUniquesCapacity * 4) with Hashable:
final class NamedTypeUniques extends HashSet[NamedType](Config.initialUniquesCapacity * 4) with Hashable with
override def hash(x: NamedType): Int = x.hash

def enterIfNew(prefix: Type, designator: Designator, isTerm: Boolean)(using Context): NamedType =
Expand All @@ -53,7 +53,7 @@ object Uniques:
addEntryAt(idx, newType)
end NamedTypeUniques

final class AppliedUniques extends HashSet[AppliedType](Config.initialUniquesCapacity * 2) with Hashable:
final class AppliedUniques extends HashSet[AppliedType](Config.initialUniquesCapacity * 2) with Hashable with
override def hash(x: AppliedType): Int = x.hash

def enterIfNew(tycon: Type, args: List[Type]): AppliedType =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import dotty.tools.tasty.TastyFormat.CommentsSection

import java.nio.charset.StandardCharsets

class CommentPickler(pickler: TastyPickler, addrOfTree: tpd.Tree => Addr, docString: untpd.MemberDef => Option[Comment]):
class CommentPickler(pickler: TastyPickler, addrOfTree: tpd.Tree => Addr, docString: untpd.MemberDef => Option[Comment]) with
private val buf = new TastyBuffer(5000)
pickler.newSection(CommentsSection, buf)

Expand Down
Loading