Skip to content

Commit a1ae7f9

Browse files
committed
Drop NamedType.withSym
1 parent 24ca6c0 commit a1ae7f9

File tree

6 files changed

+15
-26
lines changed

6 files changed

+15
-26
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
382382
val targs = tp.argTypes
383383
val tycon = tp.typeConstructor
384384
New(tycon)
385-
.select(TermRef.withSym(tycon, constr))
385+
.select(TermRef(tycon, constr))
386386
.appliedToTypes(targs)
387387
.appliedToArgs(args)
388388
}
@@ -926,7 +926,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
926926
}
927927
else denot.asSingleDenotation.termRef
928928
val fun = receiver
929-
.select(TermRef.withSym(receiver.tpe, selected.termSymbol.asTerm))
929+
.select(TermRef(receiver.tpe, selected.termSymbol.asTerm))
930930
.appliedToTypes(targs)
931931

932932
def adaptLastArg(lastParam: Tree, expectedType: Type) = {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,7 @@ object SymDenotations {
14051405
private def computeThisType(implicit ctx: Context): Type = {
14061406
val cls = symbol.asType
14071407
val pre = if (this is Package) NoPrefix else owner.thisType
1408-
ThisType.raw(TypeRef.withSym(pre, cls))
1408+
ThisType.raw(TypeRef(pre, cls))
14091409
}
14101410

14111411
private[this] var myTypeRef: TypeRef = null

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

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ object Types {
709709
final def implicitMembers(implicit ctx: Context): List[TermRef] = track("implicitMembers") {
710710
memberDenots(implicitFilter,
711711
(name, buf) => buf ++= member(name).altsWith(_ is Implicit))
712-
.toList.map(d => TermRef.withSym(this, d.symbol.asTerm))
712+
.toList.map(d => TermRef(this, d.symbol.asTerm))
713713
}
714714

715715
/** The set of member classes of this type */
@@ -1141,7 +1141,7 @@ object Types {
11411141

11421142
/** The type <this . name> with either `sym` or its signed name as designator, reduced if possible */
11431143
def select(sym: Symbol)(implicit ctx: Context): Type =
1144-
NamedType.withSym(this, sym).reduceProjection
1144+
NamedType(this, sym).reduceProjection
11451145

11461146
def select(name: TermName)(implicit ctx: Context): TermRef =
11471147
TermRef(this, name, member(name))
@@ -2019,43 +2019,32 @@ object Types {
20192019
def apply(prefix: Type, designator: Name, denot: Denotation)(implicit ctx: Context) =
20202020
if (designator.isTermName) TermRef.apply(prefix, designator.asTermName, denot)
20212021
else TypeRef.apply(prefix, designator.asTypeName, denot)
2022-
def withSym(prefix: Type, sym: Symbol)(implicit ctx: Context): NamedType =
2023-
if (sym.isType) TypeRef.withSym(prefix, sym.asType)
2024-
else TermRef.withSym(prefix, sym.asTerm)
20252022
}
20262023

20272024
object TermRef {
20282025

2029-
/** Create term ref with given name, without specifying a signature.
2030-
* Its meaning is the (potentially multi-) denotation of the member(s)
2031-
* of prefix with given name.
2032-
*/
2026+
/** Create a term ref with given designator */
20332027
def apply(prefix: Type, desig: Designator)(implicit ctx: Context): TermRef =
20342028
ctx.uniqueNamedTypes.enterIfNew(prefix, desig, isTerm = true).asInstanceOf[TermRef]
20352029

2036-
/** Create term ref to given initial denotation, taking the signature
2037-
* from the denotation if it is completed, or creating a term ref without
2038-
* signature, if denotation is not yet completed.
2030+
/** Create a term ref with given initial denotation. The name of the reference is taken
2031+
* from the denotation's symbol if the latter exists, or else it is the given name.
20392032
*/
20402033
def apply(prefix: Type, name: TermName, denot: Denotation)(implicit ctx: Context): TermRef =
20412034
apply(prefix, if (denot.symbol.exists) denot.symbol.asTerm else name).withDenot(denot)
2042-
2043-
def withSym(prefix: Type, sym: TermSymbol)(implicit ctx: Context): TermRef =
2044-
apply(prefix, sym) // ###
20452035
}
20462036

20472037
object TypeRef {
20482038

2049-
/** Create type ref with given prefix and name */
2039+
/** Create a type ref with given prefix and name */
20502040
def apply(prefix: Type, desig: Designator)(implicit ctx: Context): TypeRef =
20512041
ctx.uniqueNamedTypes.enterIfNew(prefix, desig, isTerm = false).asInstanceOf[TypeRef]
20522042

2053-
/** Create a type ref with given name and initial denotation */
2043+
/** Create a type ref with given initial denotation. The name of the reference is taken
2044+
* from the denotation's symbol if the latter exists, or else it is the given name.
2045+
*/
20542046
def apply(prefix: Type, name: TypeName, denot: Denotation)(implicit ctx: Context): TypeRef =
20552047
apply(prefix, if (denot.symbol.exists) denot.symbol.asType else name).withDenot(denot)
2056-
2057-
def withSym(prefix: Type, sym: TypeSymbol)(implicit ctx: Context): TypeRef =
2058-
apply(prefix, sym) // ###
20592048
}
20602049

20612050
// --- Other SingletonTypes: ThisType/SuperType/ConstantType ---------------------------

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ class TreeUnpickler(reader: TastyReader, nameAtRef: NameRef => TermName, posUnpi
352352
private def readSymNameRef()(implicit ctx: Context): Type = {
353353
val sym = readSymRef()
354354
val prefix = readType()
355-
val res = NamedType.withSym(prefix, sym)
355+
val res = NamedType(prefix, sym)
356356
prefix match {
357357
case prefix: ThisType if prefix.cls eq sym.owner => res.withDenot(sym.denot)
358358
// without this precaution we get an infinite cycle when unpickling pos/extmethods.scala

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
386386
val companion = cls.companionModule
387387
if (companion.isTerm) {
388388
val prefix = receiver.tpe.baseType(cls).normalizedPrefix
389-
if (prefix.exists) selectGetter(ref(TermRef.withSym(prefix, companion.asTerm)))
389+
if (prefix.exists) selectGetter(ref(TermRef(prefix, companion.asTerm)))
390390
else EmptyTree
391391
}
392392
else EmptyTree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ class TermRefSet(implicit ctx: Context) extends mutable.Traversable[TermRef] {
11341134
override def foreach[U](f: TermRef => U): Unit =
11351135
for (sym <- elems.keysIterator)
11361136
for (pre <- elems(sym))
1137-
f(TermRef.withSym(pre, sym))
1137+
f(TermRef(pre, sym))
11381138
}
11391139

11401140
@sharable object EmptyTermRefSet extends TermRefSet()(NoContext)

0 commit comments

Comments
 (0)