Skip to content

Commit c582c7c

Browse files
committed
Eliminate termRefWithSig and valRef
Also, drop signature parameter in TermRef.withSigAndDenot
1 parent 735b1e7 commit c582c7c

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
@@ -652,25 +652,11 @@ object Denotations {
652652
def termRef(implicit ctx: Context): TermRef =
653653
TermRef(symbol.owner.thisType, symbol.name.asTermName, this)
654654

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

675661
// ------ Transformations -----------------------------------------
676662

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
@@ -229,7 +229,7 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
229229
def makePackageObjPrefixExplicit(tpe: NamedType): Type = {
230230
def tryInsert(pkgClass: SymDenotation): Type = pkgClass match {
231231
case pkgCls: PackageClassDenotation if !(tpe.symbol.maybeOwner is Package) =>
232-
tpe.derivedSelect(pkgCls.packageObj.valRef)
232+
tpe.derivedSelect(pkgCls.packageObj.termRef)
233233
case _ =>
234234
tpe
235235
}

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

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

19641964
private def rewrap(sd: SingleDenotation)(implicit ctx: Context) =
1965-
TermRef.withSigAndDenot(prefix, name, sd.signature, sd)
1965+
TermRef.withSigAndDenot(prefix, name, sd)
19661966

19671967
def alternatives(implicit ctx: Context): List[TermRef] =
19681968
denot.alternatives map rewrap
@@ -2077,11 +2077,11 @@ object Types {
20772077
} withDenot denot
20782078

20792079
/** Create a term ref with given prefix, name, signature, and initial denotation */
2080-
def withSigAndDenot(prefix: Type, name: TermName, sig: Signature, denot: Denotation)(implicit ctx: Context): TermRef = {
2080+
def withSigAndDenot(prefix: Type, name: TermName, denot: Denotation)(implicit ctx: Context): TermRef = {
20812081
if ((prefix eq NoPrefix) || denot.symbol.isReferencedSymbolically)
20822082
apply(prefix, denot.symbol.asTerm)
20832083
else
2084-
apply(prefix, name.withSig(sig))
2084+
apply(prefix, name.withSig(denot.signature))
20852085
} withDenot denot
20862086
}
20872087

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class ImportInfo(symf: Context => Symbol, val selectors: List[untpd.Tree],
102102
for {
103103
renamed <- reverseMapping.keys
104104
denot <- pre.member(reverseMapping(renamed)).altsWith(_ is Implicit)
105-
} yield TermRef.withSigAndDenot(pre, renamed, denot.signature, denot)
105+
} yield TermRef.withSigAndDenot(pre, renamed, denot)
106106
}
107107

108108
/** The root import symbol hidden by this symbol, or NoSymbol if no such symbol is hidden.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ object Inferencing {
196196
case tp: TypeRef =>
197197
val companion = tp.classSymbol.companionModule
198198
if (companion.exists)
199-
companion.valRef.asSeenFrom(tp.prefix, companion.symbol.owner)
199+
companion.termRef.asSeenFrom(tp.prefix, companion.symbol.owner)
200200
else NoType
201201
case _ => NoType
202202
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,10 +515,10 @@ trait TypeAssigner {
515515
tree.withType(proto)
516516

517517
def assignType(tree: untpd.ValDef, sym: Symbol)(implicit ctx: Context) =
518-
tree.withType(if (sym.exists) assertExists(symbolicIfNeeded(sym).orElse(sym.valRef)) else NoType)
518+
tree.withType(if (sym.exists) assertExists(symbolicIfNeeded(sym).orElse(sym.termRef)) else NoType)
519519

520520
def assignType(tree: untpd.DefDef, sym: Symbol)(implicit ctx: Context) =
521-
tree.withType(symbolicIfNeeded(sym).orElse(sym.termRefWithSig))
521+
tree.withType(symbolicIfNeeded(sym).orElse(sym.termRef))
522522

523523
def assignType(tree: untpd.TypeDef, sym: Symbol)(implicit ctx: Context) =
524524
tree.withType(symbolicIfNeeded(sym).orElse(sym.typeRef))
@@ -545,7 +545,7 @@ trait TypeAssigner {
545545
tree.withType(AnnotatedType(arg.tpe.widen, Annotation(annot)))
546546

547547
def assignType(tree: untpd.PackageDef, pid: Tree)(implicit ctx: Context) =
548-
tree.withType(pid.symbol.valRef)
548+
tree.withType(pid.symbol.termRef)
549549

550550
/** Ensure that `tree2`'s type is in the same universe as `tree1`. If that's the case, return
551551
* `op` applied to both types.

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,7 +1517,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
15171517
ctx
15181518
}
15191519
val stats1 = typedStats(tree.stats, pkg.moduleClass)(packageContext)
1520-
cpy.PackageDef(tree)(pid1.asInstanceOf[RefTree], stats1) withType pkg.valRef
1520+
cpy.PackageDef(tree)(pid1.asInstanceOf[RefTree], stats1) withType pkg.termRef
15211521
} else errorTree(tree, i"package ${tree.pid.name} does not exist")
15221522
}
15231523

@@ -1905,8 +1905,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
19051905
def adaptOverloaded(ref: TermRef) = {
19061906
val altDenots = ref.denot.alternatives
19071907
typr.println(i"adapt overloaded $ref with alternatives ${altDenots map (_.info)}%, %")
1908-
val alts = altDenots map (alt =>
1909-
TermRef.withSigAndDenot(ref.prefix, ref.name, alt.info.signature, alt))
1908+
val alts = altDenots.map(TermRef.withSigAndDenot(ref.prefix, ref.name, _))
19101909
resolveOverloaded(alts, pt) match {
19111910
case alt :: Nil =>
19121911
adapt(tree.withType(alt), pt)

0 commit comments

Comments
 (0)