Skip to content

Commit 20344aa

Browse files
committed
Drop NamedType.withSym
1 parent 1b80b9f commit 20344aa

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
}
@@ -917,7 +917,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
917917
}
918918
else denot.asSingleDenotation.termRef
919919
val fun = receiver
920-
.select(TermRef.withSym(receiver.tpe, selected.termSymbol.asTerm))
920+
.select(TermRef(receiver.tpe, selected.termSymbol.asTerm))
921921
.appliedToTypes(targs)
922922

923923
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
@@ -1401,7 +1401,7 @@ object SymDenotations {
14011401
private def computeThisType(implicit ctx: Context): Type = {
14021402
val cls = symbol.asType
14031403
val pre = if (this is Package) NoPrefix else owner.thisType
1404-
ThisType.raw(TypeRef.withSym(pre, cls))
1404+
ThisType.raw(TypeRef(pre, cls))
14051405
}
14061406

14071407
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 */
@@ -1135,7 +1135,7 @@ object Types {
11351135

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

11401140
def select(name: TermName)(implicit ctx: Context): TermRef =
11411141
TermRef(this, name, member(name))
@@ -2010,43 +2010,32 @@ object Types {
20102010
def apply(prefix: Type, designator: Name, denot: Denotation)(implicit ctx: Context) =
20112011
if (designator.isTermName) TermRef.apply(prefix, designator.asTermName, denot)
20122012
else TypeRef.apply(prefix, designator.asTypeName, denot)
2013-
def withSym(prefix: Type, sym: Symbol)(implicit ctx: Context): NamedType =
2014-
if (sym.isType) TypeRef.withSym(prefix, sym.asType)
2015-
else TermRef.withSym(prefix, sym.asTerm)
20162013
}
20172014

20182015
object TermRef {
20192016

2020-
/** Create term ref with given name, without specifying a signature.
2021-
* Its meaning is the (potentially multi-) denotation of the member(s)
2022-
* of prefix with given name.
2023-
*/
2017+
/** Create a term ref with given designator */
20242018
def apply(prefix: Type, desig: Designator)(implicit ctx: Context): TermRef =
20252019
ctx.uniqueNamedTypes.enterIfNew(prefix, desig, isTerm = true).asInstanceOf[TermRef]
20262020

2027-
/** Create term ref to given initial denotation, taking the signature
2028-
* from the denotation if it is completed, or creating a term ref without
2029-
* signature, if denotation is not yet completed.
2021+
/** Create a term ref with given initial denotation. The name of the reference is taken
2022+
* from the denotation's symbol if the latter exists, or else it is the given name.
20302023
*/
20312024
def apply(prefix: Type, name: TermName, denot: Denotation)(implicit ctx: Context): TermRef =
20322025
apply(prefix, if (denot.symbol.exists) denot.symbol.asTerm else name).withDenot(denot)
2033-
2034-
def withSym(prefix: Type, sym: TermSymbol)(implicit ctx: Context): TermRef =
2035-
apply(prefix, sym) // ###
20362026
}
20372027

20382028
object TypeRef {
20392029

2040-
/** Create type ref with given prefix and name */
2030+
/** Create a type ref with given prefix and name */
20412031
def apply(prefix: Type, desig: Designator)(implicit ctx: Context): TypeRef =
20422032
ctx.uniqueNamedTypes.enterIfNew(prefix, desig, isTerm = false).asInstanceOf[TypeRef]
20432033

2044-
/** Create a type ref with given name and initial denotation */
2034+
/** Create a type ref with given initial denotation. The name of the reference is taken
2035+
* from the denotation's symbol if the latter exists, or else it is the given name.
2036+
*/
20452037
def apply(prefix: Type, name: TypeName, denot: Denotation)(implicit ctx: Context): TypeRef =
20462038
apply(prefix, if (denot.symbol.exists) denot.symbol.asType else name).withDenot(denot)
2047-
2048-
def withSym(prefix: Type, sym: TypeSymbol)(implicit ctx: Context): TypeRef =
2049-
apply(prefix, sym) // ###
20502039
}
20512040

20522041
// --- 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
@@ -385,7 +385,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
385385
val companion = cls.companionModule
386386
if (companion.isTerm) {
387387
val prefix = receiver.tpe.baseType(cls).normalizedPrefix
388-
if (prefix.exists) selectGetter(ref(TermRef.withSym(prefix, companion.asTerm)))
388+
if (prefix.exists) selectGetter(ref(TermRef(prefix, companion.asTerm)))
389389
else EmptyTree
390390
}
391391
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)