@@ -707,10 +707,7 @@ object Types {
707707 final def implicitMembers (implicit ctx : Context ): List [TermRef ] = track(" implicitMembers" ) {
708708 memberDenots(implicitFilter,
709709 (name, buf) => buf ++= member(name).altsWith(_ is Implicit ))
710- .toList.map { d =>
711- val mbr = d.symbol.asTerm
712- TermRef (this , mbr, mbr.name)
713- }
710+ .toList.map(d => TermRef .withSym(this , d.symbol.asTerm))
714711 }
715712
716713 /** The set of member classes of this type */
@@ -1136,7 +1133,7 @@ object Types {
11361133
11371134 /** The type <this . name> with either `sym` or its signed name as designator, reduced if possible */
11381135 def select (sym : Symbol )(implicit ctx : Context ): Type =
1139- NamedType (this , sym, sym.name ).reduceProjection
1136+ NamedType .withSym (this , sym).reduceProjection
11401137
11411138// ----- Access to parts --------------------------------------------
11421139
@@ -2034,9 +2031,9 @@ object Types {
20342031 def apply (prefix : Type , designator : Name , denot : Denotation )(implicit ctx : Context ) =
20352032 if (designator.isTermName) TermRef (prefix, designator.asTermName, denot)
20362033 else TypeRef (prefix, designator.asTypeName, denot)
2037- def apply (prefix : Type , sym : Symbol , name : Name )(implicit ctx : Context ): NamedType =
2038- if (sym.isType) TypeRef .apply (prefix, sym.asType, name.asTypeName )
2039- else TermRef .apply (prefix, sym.asTerm, name.asTermName )
2034+ def withSym (prefix : Type , sym : Symbol )(implicit ctx : Context ): NamedType =
2035+ if (sym.isType) TypeRef .withSym (prefix, sym.asType)
2036+ else TermRef .withSym (prefix, sym.asTerm)
20402037 }
20412038
20422039 object TermRef {
@@ -2048,15 +2045,6 @@ object Types {
20482045 def apply (prefix : Type , designator : TermDesignator )(implicit ctx : Context ): TermRef =
20492046 ctx.uniqueNamedTypes.enterIfNew(prefix, designator, isTerm = true ).asInstanceOf [TermRef ]
20502047
2051- /** Create a term ref referring to given symbol with given name.
2052- * This is similar to TermRef(Type, Symbol), except:
2053- * (1) the symbol might not yet have a denotation, so the name needs to be given explicitly.
2054- * (2) the designator of the TermRef is either the symbol or its name & unforced signature.
2055- */
2056- def apply (prefix : Type , sym : TermSymbol , name : TermName )(implicit ctx : Context ): TermRef =
2057- if ((prefix eq NoPrefix ) || sym.isReferencedSymbolically) apply(prefix, sym)
2058- else apply(prefix, name.withSig(sym.signature)).withSym(sym)
2059-
20602048 /** Create term ref to given initial denotation, taking the signature
20612049 * from the denotation if it is completed, or creating a term ref without
20622050 * signature, if denotation is not yet completed.
@@ -2068,6 +2056,18 @@ object Types {
20682056 case _ => apply(prefix, name)
20692057 }
20702058 } withDenot denot
2059+
2060+ /** Create a term ref referring to given symbol with given name.
2061+ * This is similar to TermRef(Type, Symbol), except:
2062+ * (1) the symbol might not yet have a denotation, so the name needs to be given explicitly.
2063+ * (2) the designator of the TermRef is either the symbol or its name & unforced signature.
2064+ */
2065+ def withSym (prefix : Type , sym : TermSymbol , name : TermName )(implicit ctx : Context ): TermRef =
2066+ if ((prefix eq NoPrefix ) || sym.isReferencedSymbolically) apply(prefix, sym)
2067+ else apply(prefix, name.withSig(sym.signature)).withSym(sym)
2068+
2069+ def withSym (prefix : Type , sym : TermSymbol )(implicit ctx : Context ): TermRef =
2070+ withSym(prefix, sym, sym.name)
20712071 }
20722072
20732073 object TypeRef {
@@ -2076,20 +2076,23 @@ object Types {
20762076 def apply (prefix : Type , desig : TypeDesignator )(implicit ctx : Context ): TypeRef =
20772077 ctx.uniqueNamedTypes.enterIfNew(prefix, desig, isTerm = false ).asInstanceOf [TypeRef ]
20782078
2079+ /** Create a type ref with given name and initial denotation */
2080+ def apply (prefix : Type , name : TypeName , denot : Denotation )(implicit ctx : Context ): TypeRef = {
2081+ if ((prefix eq NoPrefix ) || denot.symbol.isReferencedSymbolically) apply(prefix, denot.symbol.asType)
2082+ else apply(prefix, name)
2083+ } withDenot denot
2084+
20792085 /** Create a type ref referring to either a given symbol or its name.
20802086 * This is similar to TypeRef(prefix, sym), except:
20812087 * (1) the symbol might not yet have a denotation, so the name needs to be given explicitly.
20822088 * (2) the designator of the TypeRef is either the symbol or its name
20832089 */
2084- def apply (prefix : Type , sym : TypeSymbol , name : TypeName )(implicit ctx : Context ): TypeRef =
2090+ def withSym (prefix : Type , sym : TypeSymbol , name : TypeName )(implicit ctx : Context ): TypeRef =
20852091 if ((prefix eq NoPrefix ) || sym.isReferencedSymbolically) apply(prefix, sym)
20862092 else apply(prefix, name).withSym(sym)
20872093
2088- /** Create a type ref with given name and initial denotation */
2089- def apply (prefix : Type , name : TypeName , denot : Denotation )(implicit ctx : Context ): TypeRef = {
2090- if ((prefix eq NoPrefix ) || denot.symbol.isReferencedSymbolically) apply(prefix, denot.symbol.asType)
2091- else apply(prefix, name)
2092- } withDenot denot
2094+ def withSym (prefix : Type , sym : TypeSymbol )(implicit ctx : Context ): TypeRef =
2095+ withSym(prefix, sym, sym.name)
20932096 }
20942097
20952098 // --- Other SingletonTypes: ThisType/SuperType/ConstantType ---------------------------
@@ -3374,7 +3377,7 @@ object Types {
33743377 appliedRefCache
33753378 }
33763379
3377- def symbolicTypeRef (implicit ctx : Context ): TypeRef = TypeRef (prefix, cls, cls.name )
3380+ def symbolicTypeRef (implicit ctx : Context ): TypeRef = TypeRef .withSym (prefix, cls)
33783381
33793382 // cached because baseType needs parents
33803383 private [this ] var parentsCache : List [Type ] = null
0 commit comments