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