@@ -1123,6 +1123,11 @@ object Types {
1123
1123
loop(this )
1124
1124
}
1125
1125
1126
+ private def isReferencedSymbolically (sym : Symbol )(implicit ctx : Context ) =
1127
+ sym.isFresh ||
1128
+ sym.isClass && sym.is(Scala2x ) && ! sym.owner.is(Package ) ||
1129
+ ctx.phase.symbolicRefs
1130
+
1126
1131
/** The type <this . name> , reduced if possible */
1127
1132
def select (name : Name )(implicit ctx : Context ): Type = name match {
1128
1133
case name : TermName => TermRef (this , name)
@@ -1137,8 +1142,8 @@ object Types {
1137
1142
1138
1143
/** The type <this . name> with given symbol, reduced if possible */
1139
1144
def select (sym : Symbol )(implicit ctx : Context ): Type =
1140
- if (sym.isTerm) TermRef (this , sym.asTerm)
1141
- else TypeRef (this , sym.asType).reduceProjection
1145
+ if (sym.isTerm) TermRef .withSym (this , sym.asTerm)
1146
+ else TypeRef .withSym (this , sym.asType).reduceProjection
1142
1147
1143
1148
// ----- Access to parts --------------------------------------------
1144
1149
@@ -1975,7 +1980,7 @@ object Types {
1975
1980
1976
1981
def newLikeThis (prefix : Type )(implicit ctx : Context ): NamedType = designator match {
1977
1982
case designator : TermSymbol =>
1978
- TermRef .withFixedSym (prefix, designator)
1983
+ TermRef (prefix, designator)
1979
1984
case designator : TermName =>
1980
1985
// If symbol exists, the new signature is the symbol's signature as seen
1981
1986
// from the new prefix, modulo consistency
@@ -2027,12 +2032,12 @@ object Types {
2027
2032
def apply (prefix : Type , designator : Name )(implicit ctx : Context ) =
2028
2033
if (designator.isTermName) TermRef (prefix, designator.asTermName)
2029
2034
else TypeRef (prefix, designator.asTypeName)
2035
+ def apply (prefix : Type , sym : Symbol )(implicit ctx : Context ) =
2036
+ if (sym.isType) TypeRef (prefix, sym.asType)
2037
+ else TermRef (prefix, sym.asTerm)
2030
2038
def apply (prefix : Type , designator : Name , denot : Denotation )(implicit ctx : Context ) =
2031
2039
if (designator.isTermName) TermRef (prefix, designator.asTermName, denot)
2032
2040
else TypeRef (prefix, designator.asTypeName, denot)
2033
- def withFixedSym (prefix : Type , sym : Symbol )(implicit ctx : Context ) =
2034
- if (sym.isType) TypeRef .withFixedSym(prefix, sym.asType)
2035
- else TermRef .withFixedSym(prefix, sym.asTerm)
2036
2041
def withSymAndName (prefix : Type , sym : Symbol , name : Name )(implicit ctx : Context ): NamedType =
2037
2042
if (sym.isType) TypeRef .withSymAndName(prefix, sym.asType, name.asTypeName)
2038
2043
else TermRef .withSymAndName(prefix, sym.asTerm, name.asTermName)
@@ -2046,14 +2051,14 @@ object Types {
2046
2051
* Its meaning is the (potentially multi-) denotation of the member(s)
2047
2052
* of prefix with given name.
2048
2053
*/
2049
- def apply (prefix : Type , designator : TermName )(implicit ctx : Context ): TermRef =
2054
+ def apply (prefix : Type , designator : TermDesignator )(implicit ctx : Context ): TermRef =
2050
2055
ctx.uniqueNamedTypes.enterIfNew(prefix, designator, isTerm = true ).asInstanceOf [TermRef ]
2051
2056
2052
2057
/** Create term ref referring to given symbol, taking the signature
2053
2058
* from the symbol if it is completed, or creating a term ref without
2054
2059
* signature, if symbol is not yet completed.
2055
2060
*/
2056
- def apply (prefix : Type , sym : TermSymbol )(implicit ctx : Context ): TermRef =
2061
+ def withSym (prefix : Type , sym : TermSymbol )(implicit ctx : Context ): TermRef =
2057
2062
withSymAndName(prefix, sym, sym.name)
2058
2063
2059
2064
/** Create term ref to given initial denotation, taking the signature
@@ -2062,19 +2067,13 @@ object Types {
2062
2067
*/
2063
2068
def apply (prefix : Type , designator : TermName , denot : Denotation )(implicit ctx : Context ): TermRef = {
2064
2069
if ((prefix eq NoPrefix ) || denot.symbol.isFresh || symbolicRefs)
2065
- apply (prefix, denot.symbol.asTerm)
2070
+ withSym (prefix, denot.symbol.asTerm)
2066
2071
else denot match {
2067
2072
case denot : SymDenotation if denot.isCompleted => withSig(prefix, designator, denot.signature)
2068
2073
case _ => apply(prefix, designator)
2069
2074
}
2070
2075
} withDenot denot
2071
2076
2072
- /** Create a non-member term ref (which cannot be reloaded using `member`),
2073
- * with given prefix, name, and signature
2074
- */
2075
- def withFixedSym (prefix : Type , sym : TermSymbol )(implicit ctx : Context ): TermRef =
2076
- ctx.uniqueNamedTypes.enterIfNew(prefix, sym, isTerm = true ).asInstanceOf [TermRef ]
2077
-
2078
2077
/** Create a term ref referring to given symbol with given name, taking the signature
2079
2078
* from the symbol if it is completed, or creating a term ref without
2080
2079
* signature, if symbol is not yet completed. This is very similar to TermRef(Type, Symbol),
@@ -2084,7 +2083,7 @@ object Types {
2084
2083
*/
2085
2084
def withSymAndName (prefix : Type , sym : TermSymbol , name : TermName )(implicit ctx : Context ): TermRef =
2086
2085
if ((prefix eq NoPrefix ) || sym.isFresh || symbolicRefs)
2087
- withFixedSym (prefix, sym)
2086
+ apply (prefix, sym)
2088
2087
else if (sym.defRunId != NoRunId && sym.isCompleted)
2089
2088
withSig(prefix, name, sym.signature).withSym(sym)
2090
2089
// Linker note:
@@ -2098,7 +2097,7 @@ object Types {
2098
2097
* (which must be completed).
2099
2098
*/
2100
2099
def withSig (prefix : Type , sym : TermSymbol )(implicit ctx : Context ): TermRef =
2101
- if ((prefix eq NoPrefix ) || sym.isFresh || symbolicRefs) withFixedSym (prefix, sym)
2100
+ if ((prefix eq NoPrefix ) || sym.isFresh || symbolicRefs) apply (prefix, sym)
2102
2101
else withSig(prefix, sym.name, sym.signature).withSym(sym)
2103
2102
2104
2103
/** Create a term ref with given prefix, name and signature */
@@ -2108,7 +2107,7 @@ object Types {
2108
2107
/** Create a term ref with given prefix, name, signature, and initial denotation */
2109
2108
def withSigAndDenot (prefix : Type , name : TermName , sig : Signature , denot : Denotation )(implicit ctx : Context ): TermRef = {
2110
2109
if ((prefix eq NoPrefix ) || denot.symbol.isFresh || symbolicRefs)
2111
- withFixedSym (prefix, denot.symbol.asTerm)
2110
+ apply (prefix, denot.symbol.asTerm)
2112
2111
else
2113
2112
withSig(prefix, name, sig)
2114
2113
} withDenot denot
@@ -2120,28 +2119,22 @@ object Types {
2120
2119
ctx.uniqueNamedTypes.enterIfNew(prefix, desig, isTerm = false ).asInstanceOf [TypeRef ]
2121
2120
2122
2121
/** Create type ref to given symbol */
2123
- def apply (prefix : Type , sym : TypeSymbol )(implicit ctx : Context ): TypeRef =
2122
+ def withSym (prefix : Type , sym : TypeSymbol )(implicit ctx : Context ): TypeRef =
2124
2123
withSymAndName(prefix, sym, sym.name)
2125
2124
2126
- /** Create a non-member type ref (which cannot be reloaded using `member`),
2127
- * with given prefix, name, and symbol.
2128
- */
2129
- def withFixedSym (prefix : Type , sym : TypeSymbol )(implicit ctx : Context ): TypeRef =
2130
- ctx.uniqueNamedTypes.enterIfNew(prefix, sym, isTerm = false ).asInstanceOf [TypeRef ]
2131
-
2132
2125
/** Create a type ref referring to given symbol with given name.
2133
2126
* This is very similar to TypeRef(Type, Symbol),
2134
2127
* except for two differences:
2135
2128
* (1) The symbol might not yet have a denotation, so the name needs to be given explicitly.
2136
2129
* (2) The name in the type ref need not be the same as the name of the Symbol.
2137
2130
*/
2138
2131
def withSymAndName (prefix : Type , sym : TypeSymbol , name : TypeName )(implicit ctx : Context ): TypeRef =
2139
- if ((prefix eq NoPrefix ) || sym.isFresh) withFixedSym (prefix, sym)
2132
+ if ((prefix eq NoPrefix ) || sym.isFresh) apply (prefix, sym)
2140
2133
else apply(prefix, name).withSym(sym)
2141
2134
2142
2135
/** Create a type ref with given name and initial denotation */
2143
2136
def apply (prefix : Type , name : TypeName , denot : Denotation )(implicit ctx : Context ): TypeRef = {
2144
- if ((prefix eq NoPrefix ) || denot.symbol.isFresh) apply (prefix, denot.symbol.asType)
2137
+ if ((prefix eq NoPrefix ) || denot.symbol.isFresh) withSym (prefix, denot.symbol.asType)
2145
2138
else apply(prefix, name)
2146
2139
} withDenot denot
2147
2140
}
@@ -3420,15 +3413,15 @@ object Types {
3420
3413
def clsDenot = if (prefix eq cls.owner.thisType) cls.denot else cls.denot.copySymDenotation(info = this )
3421
3414
if (appliedRefCache == null ) {
3422
3415
val tref =
3423
- if ((cls is PackageClass ) || cls.owner.isTerm) symbolicTypeRef
3416
+ if ((cls is PackageClass ) || cls.owner.isTerm) symbolicTypeRef // ??? not always symbolicRef
3424
3417
else TypeRef (prefix, cls.name, clsDenot)
3425
3418
appliedRefCache =
3426
3419
tref.appliedTo(cls.typeParams.map(_.typeRef))
3427
3420
}
3428
3421
appliedRefCache
3429
3422
}
3430
3423
3431
- def symbolicTypeRef (implicit ctx : Context ): TypeRef = TypeRef (prefix, cls)
3424
+ def symbolicTypeRef (implicit ctx : Context ): TypeRef = TypeRef .withSym (prefix, cls)
3432
3425
3433
3426
// cached because baseType needs parents
3434
3427
private [this ] var parentsCache : List [Type ] = null
@@ -3493,7 +3486,7 @@ object Types {
3493
3486
case tp : ClassInfo =>
3494
3487
// Note: Taking a normal typeRef does not work here. A normal ref might contain
3495
3488
// also other information about the named type (e.g. bounds).
3496
- contains(tp.symbolicTypeRef)
3489
+ contains(tp.symbolicTypeRef) // ??? not clear
3497
3490
case _ => lo <:< tp && tp <:< hi
3498
3491
}
3499
3492
0 commit comments