Skip to content

Commit 516f35e

Browse files
authored
Merge pull request #6871 from dotty-staging/refactor-dotc3
More dotc refactorings
2 parents a35d724 + 1abbf4e commit 516f35e

33 files changed

+352
-536
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
139139
val externalEqualsNumNum: Symbol = defn.BoxesRunTimeModule.requiredMethod(nme.equalsNumNum)
140140
val externalEqualsNumChar: Symbol = NoSymbol // ctx.requiredMethod(BoxesRunTimeTypeRef, nme.equalsNumChar) // this method is private
141141
val externalEqualsNumObject: Symbol = defn.BoxesRunTimeModule.requiredMethod(nme.equalsNumObject)
142-
val externalEquals: Symbol = defn.BoxesRunTimeClass.info.decl(nme.equals_).suchThat(toDenot(_).info.firstParamTypes.size == 2).symbol
142+
val externalEquals: Symbol = defn.BoxesRunTimeModule.info.decl(nme.equals_).suchThat(toDenot(_).info.firstParamTypes.size == 2).symbol
143143
val MaxFunctionArity: Int = Definitions.MaxImplementedFunctionArity
144144
val FunctionClass: Array[Symbol] = defn.FunctionClassPerRun()
145145
val AbstractFunctionClass: Array[Symbol] = defn.AbstractFunctionClassPerRun()

compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1636,7 +1636,7 @@ class JSCodeGen()(implicit ctx: Context) {
16361636
private lazy val externalEqualsNumObject: Symbol =
16371637
defn.BoxesRunTimeModule.requiredMethod(nme.equalsNumObject)
16381638
private lazy val externalEquals: Symbol =
1639-
defn.BoxesRunTimeClass.info.decl(nme.equals_).suchThat(toDenot(_).info.firstParamTypes.size == 2).symbol
1639+
defn.BoxesRunTimeModule.info.decl(nme.equals_).suchThat(toDenot(_).info.firstParamTypes.size == 2).symbol
16401640

16411641
/** Gen JS code for a call to Any.== */
16421642
private def genEqEqPrimitive(ltpe: Type, rtpe: Type, lsrc: js.Tree, rsrc: js.Tree)(

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ object desugar {
641641
else if (isObject)
642642
parents1 = parents1 :+ scalaDot(nme.Serializable.toTypeName)
643643
if (isEnum)
644-
parents1 = parents1 :+ ref(defn.EnumType)
644+
parents1 = parents1 :+ ref(defn.EnumClass.typeRef)
645645

646646
// derived type classes of non-module classes go to their companions
647647
val (clsDerived, companionDerived) =
@@ -984,7 +984,7 @@ object desugar {
984984
def makeSelector(sel: Tree, checkMode: MatchCheck)(implicit ctx: Context): Tree =
985985
if (checkMode == MatchCheck.Exhaustive) sel
986986
else {
987-
val sel1 = Annotated(sel, New(ref(defn.UncheckedAnnotType)))
987+
val sel1 = Annotated(sel, New(ref(defn.UncheckedAnnot.typeRef)))
988988
if (checkMode != MatchCheck.None) sel1.pushAttachment(CheckIrrefutable, checkMode)
989989
sel1
990990
}
@@ -1560,7 +1560,7 @@ object desugar {
15601560
val seqType = if (ctx.compilationUnit.isJava) defn.ArrayType else defn.SeqType
15611561
Annotated(
15621562
AppliedTypeTree(ref(seqType), t),
1563-
New(ref(defn.RepeatedAnnotType), Nil :: Nil))
1563+
New(ref(defn.RepeatedAnnot.typeRef), Nil :: Nil))
15641564
} else {
15651565
assert(ctx.mode.isExpr || ctx.reporter.errorsReported || ctx.mode.is(Mode.Interactive), ctx.mode)
15661566
Select(t, op.name)

compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ object DesugarEnums {
9898
.withFlags(Synthetic)
9999
val privateValuesDef =
100100
ValDef(nme.DOLLAR_VALUES, TypeTree(),
101-
New(TypeTree(defn.EnumValuesType.appliedTo(enumClass.typeRef :: Nil)), ListOfNil))
101+
New(TypeTree(defn.EnumValuesClass.typeRef.appliedTo(enumClass.typeRef :: Nil)), ListOfNil))
102102
.withFlags(Private)
103103

104104
val valuesOfExnMessage = Apply(

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
966966
val sym = tree.symbol
967967
if (sym.is(Method)) {
968968
val setter = sym.setter.orElse {
969-
assert(sym.name.isSetterName && sym.info.firstParamTypes.nonEmpty)
969+
assert(sym.name.isSetterName && sym.info.firstParamTypes.nonEmpty, sym)
970970
sym
971971
}
972972
val qual = tree match {
@@ -1351,7 +1351,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
13511351

13521352
/** Creates the nested pairs type tree repesentation of the type trees in `ts` */
13531353
def nestedPairsTypeTree(ts: List[Tree])(implicit ctx: Context): Tree =
1354-
ts.foldRight[Tree](TypeTree(defn.UnitType))((x, acc) => AppliedTypeTree(TypeTree(defn.PairType), x :: acc :: Nil))
1354+
ts.foldRight[Tree](TypeTree(defn.UnitType))((x, acc) => AppliedTypeTree(TypeTree(defn.PairClass.typeRef), x :: acc :: Nil))
13551355

13561356
/** Replaces all positions in `tree` with zero-extent positions */
13571357
private def focusPositions(tree: Tree)(implicit ctx: Context): Tree = {

compiler/src/dotty/tools/dotc/core/Annotations.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ object Annotations {
7575
}
7676

7777
case class LazyBodyAnnotation(private var bodyExpr: Context => Tree) extends BodyAnnotation {
78+
// TODO: Make `bodyExpr` an IFT once #6865 os in bootstrap
7879
private[this] var evaluated = false
7980
private[this] var myBody: Tree = _
8081
def tree(implicit ctx: Context): Tree = {
@@ -159,17 +160,17 @@ object Annotations {
159160
object Child {
160161

161162
/** A deferred annotation to the result of a given child computation */
162-
def apply(delayedSym: Context => Symbol, span: Span)(implicit ctx: Context): Annotation = {
163+
def later(delayedSym: given Context => Symbol, span: Span)(implicit ctx: Context): Annotation = {
163164
def makeChildLater(implicit ctx: Context) = {
164-
val sym = delayedSym(ctx)
165-
New(defn.ChildAnnotType.appliedTo(sym.owner.thisType.select(sym.name, sym)), Nil)
165+
val sym = delayedSym
166+
New(defn.ChildAnnot.typeRef.appliedTo(sym.owner.thisType.select(sym.name, sym)), Nil)
166167
.withSpan(span)
167168
}
168169
deferred(defn.ChildAnnot)(makeChildLater(ctx))
169170
}
170171

171172
/** A regular, non-deferred Child annotation */
172-
def apply(sym: Symbol, span: Span)(implicit ctx: Context): Annotation = apply(_ => sym, span)
173+
def apply(sym: Symbol, span: Span)(implicit ctx: Context): Annotation = later(given _ => sym, span)
173174

174175
def unapply(ann: Annotation)(implicit ctx: Context): Option[Symbol] =
175176
if (ann.symbol == defn.ChildAnnot) {
@@ -201,7 +202,7 @@ object Annotations {
201202

202203
def ThrowsAnnotation(cls: ClassSymbol)(implicit ctx: Context): Annotation = {
203204
val tref = cls.typeRef
204-
Annotation(defn.ThrowsAnnotType.appliedTo(tref), Ident(tref))
205+
Annotation(defn.ThrowsAnnot.typeRef.appliedTo(tref), Ident(tref))
205206
}
206207

207208
/** A decorator that provides queries for specific annotations

0 commit comments

Comments
 (0)