@@ -707,10 +707,7 @@ object Types {
707
707
final def implicitMembers (implicit ctx : Context ): List [TermRef ] = track(" implicitMembers" ) {
708
708
memberDenots(implicitFilter,
709
709
(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))
714
711
}
715
712
716
713
/** The set of member classes of this type */
@@ -1136,7 +1133,7 @@ object Types {
1136
1133
1137
1134
/** The type <this . name> with either `sym` or its signed name as designator, reduced if possible */
1138
1135
def select (sym : Symbol )(implicit ctx : Context ): Type =
1139
- NamedType (this , sym, sym.name ).reduceProjection
1136
+ NamedType .withSym (this , sym).reduceProjection
1140
1137
1141
1138
// ----- Access to parts --------------------------------------------
1142
1139
@@ -2034,9 +2031,9 @@ object Types {
2034
2031
def apply (prefix : Type , designator : Name , denot : Denotation )(implicit ctx : Context ) =
2035
2032
if (designator.isTermName) TermRef (prefix, designator.asTermName, denot)
2036
2033
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)
2040
2037
}
2041
2038
2042
2039
object TermRef {
@@ -2048,15 +2045,6 @@ object Types {
2048
2045
def apply (prefix : Type , designator : TermDesignator )(implicit ctx : Context ): TermRef =
2049
2046
ctx.uniqueNamedTypes.enterIfNew(prefix, designator, isTerm = true ).asInstanceOf [TermRef ]
2050
2047
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
-
2060
2048
/** Create term ref to given initial denotation, taking the signature
2061
2049
* from the denotation if it is completed, or creating a term ref without
2062
2050
* signature, if denotation is not yet completed.
@@ -2068,6 +2056,18 @@ object Types {
2068
2056
case _ => apply(prefix, name)
2069
2057
}
2070
2058
} 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)
2071
2071
}
2072
2072
2073
2073
object TypeRef {
@@ -2076,20 +2076,23 @@ object Types {
2076
2076
def apply (prefix : Type , desig : TypeDesignator )(implicit ctx : Context ): TypeRef =
2077
2077
ctx.uniqueNamedTypes.enterIfNew(prefix, desig, isTerm = false ).asInstanceOf [TypeRef ]
2078
2078
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
+
2079
2085
/** Create a type ref referring to either a given symbol or its name.
2080
2086
* This is similar to TypeRef(prefix, sym), except:
2081
2087
* (1) the symbol might not yet have a denotation, so the name needs to be given explicitly.
2082
2088
* (2) the designator of the TypeRef is either the symbol or its name
2083
2089
*/
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 =
2085
2091
if ((prefix eq NoPrefix ) || sym.isReferencedSymbolically) apply(prefix, sym)
2086
2092
else apply(prefix, name).withSym(sym)
2087
2093
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)
2093
2096
}
2094
2097
2095
2098
// --- Other SingletonTypes: ThisType/SuperType/ConstantType ---------------------------
@@ -3374,7 +3377,7 @@ object Types {
3374
3377
appliedRefCache
3375
3378
}
3376
3379
3377
- def symbolicTypeRef (implicit ctx : Context ): TypeRef = TypeRef (prefix, cls, cls.name )
3380
+ def symbolicTypeRef (implicit ctx : Context ): TypeRef = TypeRef .withSym (prefix, cls)
3378
3381
3379
3382
// cached because baseType needs parents
3380
3383
private [this ] var parentsCache : List [Type ] = null
0 commit comments