Skip to content

Commit 2d09c71

Browse files
committed
Drop nonMemberTermRef
Make nonMemberTermRef redundant by marking local dummies and import symbols as Fresh (i.e. they are non-members).
1 parent 1e45b0d commit 2d09c71

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
243243
val localDummy = ((NoSymbol: Symbol) /: body)(findLocalDummy.apply)
244244
.orElse(ctx.newLocalDummy(cls))
245245
val impl = untpd.Template(constr, parents, selfType, newTypeParams ++ body)
246-
.withType(localDummy.nonMemberTermRef)
246+
.withType(localDummy.termRef)
247247
ta.assignType(untpd.TypeDef(cls.name, impl), cls)
248248
}
249249

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,9 +1135,6 @@ object SymDenotations {
11351135
override def termRefWithSig(implicit ctx: Context): TermRef =
11361136
TermRef.withSigAndDenot(owner.thisType, name.asTermName, signature, this)
11371137

1138-
def nonMemberTermRef(implicit ctx: Context): TermRef =
1139-
TermRef(owner.thisType, symbol.asTerm)
1140-
11411138
/** The variance of this type parameter or type member as an Int, with
11421139
* +1 = Covariant, -1 = Contravariant, 0 = Nonvariant, or not a type parameter
11431140
*/

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,12 @@ trait Symbols { this: Context =>
249249
newSymbol(cls, nme.localDummyName(cls), Fresh, NoType)
250250

251251
/** Create an import symbol pointing back to given qualifier `expr`. */
252-
def newImportSymbol(owner: Symbol, expr: Tree, coord: Coord = NoCoord) =
253-
newSymbol(owner, nme.IMPORT, EmptyFlags, ImportType(expr), coord = coord)
252+
def newImportSymbol(owner: Symbol, expr: Tree, coord: Coord = NoCoord): TermSymbol =
253+
newImportSymbol(owner, ImportType(expr), coord = coord)
254+
255+
/** Create an import symbol with given `info`. */
256+
def newImportSymbol(owner: Symbol, info: Type, coord: Coord): TermSymbol =
257+
newSymbol(owner, nme.IMPORT, Synthetic | Fresh, info, coord = coord)
254258

255259
/** Create a class constructor symbol for given class `cls`. */
256260
def newConstructor(cls: ClassSymbol, flags: FlagSet, paramNames: List[TermName], paramTypes: List[Type], privateWithin: Symbol = NoSymbol, coord: Coord = NoCoord) =

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ class TreeUnpickler(reader: TastyReader, nameAtRef: NameRef => TermName, posUnpi
753753
})
754754
setPos(start,
755755
untpd.Template(constr, parents, self, lazyStats)
756-
.withType(localDummy.nonMemberTermRef))
756+
.withType(localDummy.termRef))
757757
}
758758

759759
def skipToplevel()(implicit ctx: Context): Unit= {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,7 @@ class Namer { typer: Typer =>
324324
adjustIfModule(completer, tree),
325325
privateWithinClass(tree.mods), tree.namePos), tree)
326326
case tree: Import =>
327-
recordSym(ctx.newSymbol(
328-
ctx.owner, nme.IMPORT, Synthetic | Fresh, new Completer(tree), NoSymbol, tree.pos), tree)
327+
recordSym(ctx.newImportSymbol(ctx.owner, new Completer(tree), tree.pos), tree)
329328
case _ =>
330329
NoSymbol
331330
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,12 +523,12 @@ trait TypeAssigner {
523523
def assignType(tree: untpd.TypeDef, sym: Symbol)(implicit ctx: Context) =
524524
tree.withType(symbolicIfNeeded(sym).orElse(sym.typeRef))
525525

526-
private def symbolicIfNeeded(sym: Symbol)(implicit ctx: Context) = {
526+
private def symbolicIfNeeded(sym: Symbol)(implicit ctx: Context) = { // ??? can we drop this?
527527
val owner = sym.owner
528528
if (owner.isClass && owner.isCompleted && owner.asClass.givenSelfType.exists)
529529
// In that case a simple typeRef/termWithWithSig could return a member of
530530
// the self type, not the symbol itself. To avoid this, we make the reference
531-
// symbolic. In general it seems to be faster to keep the non-symblic
531+
// symbolic. In general it seems to be faster to keep the non-symbolic
532532
// reference, since there is less pressure on the uniqueness tables that way
533533
// and less work to update all the different references. That's why symbolic references
534534
// are only used if necessary.
@@ -539,7 +539,7 @@ trait TypeAssigner {
539539
def assertExists(tp: Type) = { assert(tp != NoType); tp }
540540

541541
def assignType(tree: untpd.Import, sym: Symbol)(implicit ctx: Context) =
542-
tree.withType(sym.nonMemberTermRef)
542+
tree.withType(sym.termRef)
543543

544544
def assignType(tree: untpd.Annotated, arg: Tree, annot: Tree)(implicit ctx: Context) =
545545
tree.withType(AnnotatedType(arg.tpe.widen, Annotation(annot)))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
14101410

14111411
checkNoDoubleDefs(cls)
14121412
val impl1 = cpy.Template(impl)(constr1, parents1, self1, body1)
1413-
.withType(dummy.nonMemberTermRef)
1413+
.withType(dummy.termRef)
14141414
checkVariance(impl1)
14151415
if (!cls.is(AbstractOrTrait) && !ctx.isAfterTyper)
14161416
checkRealizableBounds(cls, cdef.namePos)

0 commit comments

Comments
 (0)