Skip to content

Commit 98d8ecf

Browse files
committed
Eliminate termRefWithSig and valRef
Also, drop signature parameter in TermRef.withSigAndDenot
1 parent 760479b commit 98d8ecf

14 files changed

+19
-40
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ object desugar {
10571057
} else if (arity == 1) ts.head
10581058
else if (ctx.mode is Mode.Type) AppliedTypeTree(ref(tupleTypeRef), ts)
10591059
else if (arity == 0) unitLiteral
1060-
else Apply(ref(tupleTypeRef.classSymbol.companionModule.valRef), ts)
1060+
else Apply(ref(tupleTypeRef.classSymbol.companionModule.termRef), ts)
10611061
case WhileDo(cond, body) =>
10621062
// { <label> def while$(): Unit = if (cond) { body; while$() } ; while$() }
10631063
val call = Apply(Ident(nme.WHILE_PREFIX), Nil).withPos(tree.pos)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
703703
}
704704
else
705705
TermRef.withSigAndDenot(tree.tpe, sym.name.asTermName,
706-
sym.signature, sym.denot.asSeenFrom(tree.tpe))
706+
sym.denot.asSeenFrom(tree.tpe))
707707
untpd.Select(tree, sym.name).withType(tp)
708708
}
709709

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ object Annotations {
140140

141141
def makeAlias(sym: TermSymbol)(implicit ctx: Context) =
142142
apply(defn.AliasAnnot, List(
143-
ref(TermRef.withSigAndDenot(sym.owner.thisType, sym.name, sym.signature, sym))))
143+
ref(TermRef.withSigAndDenot(sym.owner.thisType, sym.name, sym))))
144144

145145
def makeChild(delayedSym: Context => Symbol)(implicit ctx: Context): Annotation = {
146146
def makeChildLater(implicit ctx: Context) = {

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

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -653,25 +653,11 @@ object Denotations {
653653
def termRef(implicit ctx: Context): TermRef =
654654
TermRef(symbol.owner.thisType, symbol.name.asTermName, this)
655655

656-
/** The TermRef representing this term denotation at its original location
657-
* and at signature `NotAMethod`.
658-
*/
659-
def valRef(implicit ctx: Context): TermRef =
660-
TermRef.withSigAndDenot(symbol.owner.thisType, symbol.name.asTermName, Signature.NotAMethod, this)
661-
662-
/** The TermRef representing this term denotation at its original location
663-
* at the denotation's signature.
664-
* @note Unlike `valRef` and `termRef`, this will force the completion of the
665-
* denotation via a call to `info`.
666-
*/
667-
def termRefWithSig(implicit ctx: Context): TermRef =
668-
TermRef.withSigAndDenot(symbol.owner.thisType, symbol.name.asTermName, signature, this)
669-
670656
/** The NamedType representing this denotation at its original location.
671-
* Same as either `typeRef` or `termRefWithSig` depending whether this denotes a type or not.
657+
* Same as either `typeRef` or `termRef` depending whether this denotes a type or not.
672658
*/
673659
def namedType(implicit ctx: Context): NamedType =
674-
if (isType) typeRef else termRefWithSig
660+
if (isType) typeRef else termRef
675661

676662
// ------ Transformations -----------------------------------------
677663

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ object Scopes {
409409
while (e ne null) {
410410
if (e.sym is Implicit) {
411411
val d = e.sym.denot
412-
irefs += TermRef.withSigAndDenot(NoPrefix, d.name.asTermName, d.signature, d)
412+
irefs += TermRef(NoPrefix, d.symbol.asTerm).withDenot(d)
413413
}
414414
e = e.prev
415415
}

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,12 +1129,6 @@ object SymDenotations {
11291129
override def termRef(implicit ctx: Context): TermRef =
11301130
TermRef(owner.thisType, name.asTermName, this)
11311131

1132-
override def valRef(implicit ctx: Context): TermRef =
1133-
TermRef.withSigAndDenot(owner.thisType, name.asTermName, Signature.NotAMethod, this)
1134-
1135-
override def termRefWithSig(implicit ctx: Context): TermRef =
1136-
TermRef.withSigAndDenot(owner.thisType, name.asTermName, signature, this)
1137-
11381132
/** The variance of this type parameter or type member as an Int, with
11391133
* +1 = Covariant, -1 = Contravariant, 0 = Nonvariant, or not a type parameter
11401134
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
219219
def makePackageObjPrefixExplicit(tpe: NamedType): Type = {
220220
def tryInsert(pkgClass: SymDenotation): Type = pkgClass match {
221221
case pkgCls: PackageClassDenotation if !(tpe.symbol.maybeOwner is Package) =>
222-
tpe.derivedSelect(pkgCls.packageObj.valRef)
222+
tpe.derivedSelect(pkgCls.packageObj.termRef)
223223
case _ =>
224224
tpe
225225
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,7 +1957,7 @@ object Types {
19571957
override def isOverloaded(implicit ctx: Context) = denot.isOverloaded
19581958

19591959
private def rewrap(sd: SingleDenotation)(implicit ctx: Context) =
1960-
TermRef.withSigAndDenot(prefix, name, sd.signature, sd)
1960+
TermRef.withSigAndDenot(prefix, name, sd)
19611961

19621962
def alternatives(implicit ctx: Context): List[TermRef] =
19631963
denot.alternatives map rewrap
@@ -2072,11 +2072,11 @@ object Types {
20722072
} withDenot denot
20732073

20742074
/** Create a term ref with given prefix, name, signature, and initial denotation */
2075-
def withSigAndDenot(prefix: Type, name: TermName, sig: Signature, denot: Denotation)(implicit ctx: Context): TermRef = {
2075+
def withSigAndDenot(prefix: Type, name: TermName, denot: Denotation)(implicit ctx: Context): TermRef = {
20762076
if ((prefix eq NoPrefix) || denot.symbol.isReferencedSymbolically)
20772077
apply(prefix, denot.symbol.asTerm)
20782078
else
2079-
apply(prefix, name.withSig(sig))
2079+
apply(prefix, name.withSig(denot.signature))
20802080
} withDenot denot
20812081
}
20822082

compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ object EtaExpansion {
2929
val liftedType = fullyDefinedType(expr.tpe.widen, "lifted expression", expr.pos)
3030
val sym = ctx.newSymbol(ctx.owner, name, EmptyFlags, liftedType, coord = positionCoord(expr.pos))
3131
defs += ValDef(sym, expr)
32-
ref(sym.valRef)
32+
ref(sym.termRef)
3333
}
3434

3535
/** Lift out common part of lhs tree taking part in an operator assignment such as

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ trait ImplicitRunInfo { self: RunInfo =>
435435
def addParentScope(parent: Type): Unit =
436436
iscopeRefs(tp.baseType(parent.typeSymbol)) foreach addRef
437437
val companion = cls.companionModule
438-
if (companion.exists) addRef(companion.valRef)
438+
if (companion.exists) addRef(companion.termRef)
439439
cls.classParents foreach addParentScope
440440
}
441441
tp.classSymbols(liftingCtx) foreach addClassScope

0 commit comments

Comments
 (0)