@@ -1502,6 +1502,7 @@ object Types {
1502
1502
1503
1503
def isType = isInstanceOf [TypeRef ]
1504
1504
def isTerm = isInstanceOf [TermRef ]
1505
+ def hasFixedSym = designator.isInstanceOf [Symbol ]
1505
1506
1506
1507
private [this ] var myName : ThisName = _
1507
1508
private [this ] var mySig : Signature = null
@@ -1610,7 +1611,7 @@ object Types {
1610
1611
val sym = lastSymbol
1611
1612
if (sym == null ) loadDenot else denotOfSym(sym)
1612
1613
case d : SymDenotation =>
1613
- if (this . isInstanceOf [ WithFixedSym ] ) d.current
1614
+ if (hasFixedSym ) d.current
1614
1615
else if (d.validFor.runId == ctx.runId || ctx.stillValid(d))
1615
1616
if (d.exists && prefix.isTightPrefix(d.owner) || d.isConstructor) d.current
1616
1617
else recomputeMember(d) // symbol could have been overridden, recompute membership
@@ -1696,7 +1697,9 @@ object Types {
1696
1697
}
1697
1698
1698
1699
private [dotc] def withDenot (denot : Denotation )(implicit ctx : Context ): ThisType =
1699
- if (signature != denot.signature && denot.signature.ne(Signature .OverloadedSignature ))
1700
+ if (! hasFixedSym &&
1701
+ signature != denot.signature &&
1702
+ denot.signature.ne(Signature .OverloadedSignature ))
1700
1703
withSig(denot.signature).withDenot(denot).asInstanceOf [ThisType ]
1701
1704
else {
1702
1705
setDenot(denot)
@@ -1975,22 +1978,25 @@ object Types {
1975
1978
}
1976
1979
else candidate
1977
1980
1978
- def newLikeThis (prefix : Type )(implicit ctx : Context ): NamedType = {
1979
- // If symbol exists, the new signature is the symbol's signature as seen
1980
- // from the new prefix, modulo consistency
1981
- val curSig = signature
1982
- val newSig =
1983
- if (curSig == Signature .NotAMethod || ! symbol.exists)
1984
- curSig
1985
- else
1986
- curSig.updateWith(symbol.info.asSeenFrom(prefix, symbol.owner).signature)
1987
- val candidate =
1988
- if (newSig ne curSig) {
1989
- core.println(i " sig change at ${ctx.phase} for $this, pre = $prefix, sig: $curSig --> $newSig" )
1990
- TermRef .withSig(prefix, name, newSig)
1991
- }
1992
- else TermRef (prefix, designatorName.asTermName) // ###
1993
- fixDenot(candidate, prefix)
1981
+ def newLikeThis (prefix : Type )(implicit ctx : Context ): NamedType = designator match {
1982
+ case designator : TermSymbol =>
1983
+ TermRef .withFixedSym(prefix, designator)
1984
+ case designator : TermName =>
1985
+ // If symbol exists, the new signature is the symbol's signature as seen
1986
+ // from the new prefix, modulo consistency
1987
+ val curSig = signature
1988
+ val newSig =
1989
+ if (curSig == Signature .NotAMethod || ! symbol.exists)
1990
+ curSig
1991
+ else
1992
+ curSig.updateWith(symbol.info.asSeenFrom(prefix, symbol.owner).signature)
1993
+ val candidate =
1994
+ if (newSig ne curSig) {
1995
+ core.println(i " sig change at ${ctx.phase} for $this, pre = $prefix, sig: $curSig --> $newSig" )
1996
+ TermRef .withSig(prefix, name, newSig)
1997
+ }
1998
+ else TermRef (prefix, designator)
1999
+ fixDenot(candidate, prefix)
1994
2000
}
1995
2001
1996
2002
override def shadowed (implicit ctx : Context ): NamedType =
@@ -2005,41 +2011,16 @@ object Types {
2005
2011
override def underlying (implicit ctx : Context ): Type = info
2006
2012
2007
2013
def newLikeThis (prefix : Type )(implicit ctx : Context ): NamedType =
2008
- TypeRef (prefix, name) // ###
2009
- }
2010
-
2011
-
2012
- trait WithFixedSym extends NamedType {
2013
- def fixedSym : Symbol = designator.asInstanceOf [Symbol ]
2014
-
2015
- override def withDenot (denot : Denotation )(implicit ctx : Context ): ThisType = {
2016
- assert(denot.symbol eq fixedSym)
2017
- setDenot(denot)
2018
- this
2019
- }
2020
-
2021
- override def withSym (sym : Symbol )(implicit ctx : Context ): this .type =
2022
- unsupported(" withSym" )
2023
-
2024
- override def newLikeThis (prefix : Type )(implicit ctx : Context ): NamedType =
2025
- NamedType .withFixedSym(prefix, fixedSym)
2014
+ TypeRef (prefix, designator)
2026
2015
}
2027
2016
2028
2017
final class CachedTermRef (prefix : Type , designator : TermDesignator , hc : Int ) extends TermRef (prefix, designator) {
2029
- assert(prefix ne NoPrefix )
2018
+ assert(( prefix ne NoPrefix ) || hasFixedSym )
2030
2019
myHash = hc
2031
2020
}
2032
2021
2033
2022
final class CachedTypeRef (prefix : Type , designator : TypeDesignator , hc : Int ) extends TypeRef (prefix, designator) {
2034
- assert(prefix ne NoPrefix )
2035
- myHash = hc
2036
- }
2037
-
2038
- // Those classes are non final as Linker extends them.
2039
- class TermRefWithFixedSym (prefix : Type , designator : TermSymbol , hc : Int ) extends TermRef (prefix, designator) with WithFixedSym {
2040
- myHash = hc
2041
- }
2042
- class TypeRefWithFixedSym (prefix : Type , designator : TypeSymbol , hc : Int ) extends TypeRef (prefix, designator) with WithFixedSym {
2023
+ assert((prefix ne NoPrefix ) || hasFixedSym)
2043
2024
myHash = hc
2044
2025
}
2045
2026
@@ -2055,8 +2036,8 @@ object Types {
2055
2036
if (designator.isTermName) TermRef (prefix, designator.asTermName, denot)
2056
2037
else TypeRef (prefix, designator.asTypeName, denot)
2057
2038
def withFixedSym (prefix : Type , sym : Symbol )(implicit ctx : Context ) =
2058
- if (sym.isType) TypeRef .withFixedSym(prefix, sym.name.asTypeName, sym. asType)
2059
- else TermRef .withFixedSym(prefix, sym.name.asTermName, sym. asTerm)
2039
+ if (sym.isType) TypeRef .withFixedSym(prefix, sym.asType)
2040
+ else TermRef .withFixedSym(prefix, sym.asTerm)
2060
2041
def withSymAndName (prefix : Type , sym : Symbol , name : Name )(implicit ctx : Context ): NamedType =
2061
2042
if (sym.isType) TypeRef .withSymAndName(prefix, sym.asType, name.asTypeName)
2062
2043
else TermRef .withSymAndName(prefix, sym.asTerm, name.asTermName)
@@ -2096,7 +2077,7 @@ object Types {
2096
2077
/** Create a non-member term ref (which cannot be reloaded using `member`),
2097
2078
* with given prefix, name, and signature
2098
2079
*/
2099
- def withFixedSym (prefix : Type , name : TermName , sym : TermSymbol )(implicit ctx : Context ): TermRef =
2080
+ def withFixedSym (prefix : Type , sym : TermSymbol )(implicit ctx : Context ): TermRef =
2100
2081
ctx.uniqueNamedTypes.enterIfNew(prefix, sym, isTerm = true ).asInstanceOf [TermRef ]
2101
2082
2102
2083
/** Create a term ref referring to given symbol with given name, taking the signature
@@ -2108,7 +2089,7 @@ object Types {
2108
2089
*/
2109
2090
def withSymAndName (prefix : Type , sym : TermSymbol , name : TermName )(implicit ctx : Context ): TermRef =
2110
2091
if ((prefix eq NoPrefix ) || sym.isFresh || symbolicRefs)
2111
- withFixedSym(prefix, name, sym)
2092
+ withFixedSym(prefix, sym)
2112
2093
else if (sym.defRunId != NoRunId && sym.isCompleted)
2113
2094
withSig(prefix, name, sym.signature).withSym(sym)
2114
2095
// Linker note:
@@ -2122,7 +2103,7 @@ object Types {
2122
2103
* (which must be completed).
2123
2104
*/
2124
2105
def withSig (prefix : Type , sym : TermSymbol )(implicit ctx : Context ): TermRef =
2125
- if ((prefix eq NoPrefix ) || sym.isFresh || symbolicRefs) withFixedSym(prefix, sym.name, sym )
2106
+ if ((prefix eq NoPrefix ) || sym.isFresh || symbolicRefs) withFixedSym(prefix, sym)
2126
2107
else withSig(prefix, sym.name, sym.signature).withSym(sym)
2127
2108
2128
2109
/** Create a term ref with given prefix, name and signature */
@@ -2132,16 +2113,16 @@ object Types {
2132
2113
/** Create a term ref with given prefix, name, signature, and initial denotation */
2133
2114
def withSigAndDenot (prefix : Type , name : TermName , sig : Signature , denot : Denotation )(implicit ctx : Context ): TermRef = {
2134
2115
if ((prefix eq NoPrefix ) || denot.symbol.isFresh || symbolicRefs)
2135
- withFixedSym(prefix, denot.symbol.asTerm.name, denot.symbol.asTerm )
2116
+ withFixedSym(prefix, denot.symbol.asTerm)
2136
2117
else
2137
2118
withSig(prefix, name, sig)
2138
2119
} withDenot denot
2139
2120
}
2140
2121
2141
2122
object TypeRef {
2142
2123
/** Create type ref with given prefix and name */
2143
- def apply (prefix : Type , name : TypeName )(implicit ctx : Context ): TypeRef =
2144
- ctx.uniqueNamedTypes.enterIfNew(prefix, name , isTerm = false ).asInstanceOf [TypeRef ]
2124
+ def apply (prefix : Type , desig : TypeDesignator )(implicit ctx : Context ): TypeRef =
2125
+ ctx.uniqueNamedTypes.enterIfNew(prefix, desig , isTerm = false ).asInstanceOf [TypeRef ]
2145
2126
2146
2127
/** Create type ref to given symbol */
2147
2128
def apply (prefix : Type , sym : TypeSymbol )(implicit ctx : Context ): TypeRef =
@@ -2150,7 +2131,7 @@ object Types {
2150
2131
/** Create a non-member type ref (which cannot be reloaded using `member`),
2151
2132
* with given prefix, name, and symbol.
2152
2133
*/
2153
- def withFixedSym (prefix : Type , name : TypeName , sym : TypeSymbol )(implicit ctx : Context ): TypeRef =
2134
+ def withFixedSym (prefix : Type , sym : TypeSymbol )(implicit ctx : Context ): TypeRef =
2154
2135
ctx.uniqueNamedTypes.enterIfNew(prefix, sym, isTerm = false ).asInstanceOf [TypeRef ]
2155
2136
2156
2137
/** Create a type ref referring to given symbol with given name.
@@ -2160,7 +2141,7 @@ object Types {
2160
2141
* (2) The name in the type ref need not be the same as the name of the Symbol.
2161
2142
*/
2162
2143
def withSymAndName (prefix : Type , sym : TypeSymbol , name : TypeName )(implicit ctx : Context ): TypeRef =
2163
- if ((prefix eq NoPrefix ) || sym.isFresh) withFixedSym(prefix, name, sym)
2144
+ if ((prefix eq NoPrefix ) || sym.isFresh) withFixedSym(prefix, sym)
2164
2145
else apply(prefix, name).withSym(sym)
2165
2146
2166
2147
/** Create a type ref with given name and initial denotation */
0 commit comments