@@ -1581,7 +1581,7 @@ object Types {
1581
1581
1582
1582
// --- NamedTypes ------------------------------------------------------------------
1583
1583
1584
- abstract class NamedType extends CachedProxyType with ValueType { self =>
1584
+ abstract class NamedType extends CachedProxyType with ValueType with SignatureCachingType { self =>
1585
1585
1586
1586
type ThisType >: this .type <: NamedType
1587
1587
type ThisName <: Name
@@ -1593,7 +1593,6 @@ object Types {
1593
1593
assert(prefix.isValueType || (prefix eq NoPrefix ), s " invalid prefix $prefix" )
1594
1594
1595
1595
private [this ] var myName : Name = null
1596
- private [this ] var mySig : Signature = null
1597
1596
private [this ] var lastDenotation : Denotation = null
1598
1597
private [this ] var lastSymbol : Symbol = null
1599
1598
private [this ] var checkedPeriod : Period = Nowhere
@@ -1602,6 +1601,7 @@ object Types {
1602
1601
// Invariants:
1603
1602
// (1) checkedPeriod != Nowhere => lastDenotation != null
1604
1603
// (2) lastDenotation != null => lastSymbol != null
1604
+ // (3) mySigRunId != NoRunId => mySig != null
1605
1605
1606
1606
def isType = isInstanceOf [TypeRef ]
1607
1607
def isTerm = isInstanceOf [TermRef ]
@@ -1622,12 +1622,7 @@ object Types {
1622
1622
/** The signature of the last known denotation, or if there is none, the
1623
1623
* signature of the symbol
1624
1624
*/
1625
- final override def signature (implicit ctx : Context ): Signature = {
1626
- if (mySig == null ) mySig = computeSignature
1627
- mySig
1628
- }
1629
-
1630
- def computeSignature (implicit ctx : Context ): Signature = {
1625
+ protected def computeSignature (implicit ctx : Context ): Signature = {
1631
1626
val lastd = lastDenotation
1632
1627
if (lastd != null ) lastd.signature
1633
1628
else symbol.asSeenFrom(prefix).signature
@@ -1638,7 +1633,7 @@ object Types {
1638
1633
* Otherwise NotAMethod.
1639
1634
*/
1640
1635
private def currentSignature (implicit ctx : Context ): Signature =
1641
- if (mySig != null ) mySig
1636
+ if (ctx.runId == mySignatureRunId) mySignature
1642
1637
else {
1643
1638
val lastd = lastDenotation
1644
1639
if (lastd != null ) lastd.signature
@@ -2585,13 +2580,22 @@ object Types {
2585
2580
// and therefore two different poly types would never be equal.
2586
2581
2587
2582
/** A trait that mixes in functionality for signature caching */
2588
- trait MethodicType extends TermType {
2589
-
2590
- private [this ] var mySignature : Signature = _
2591
- private [this ] var mySignatureRunId : Int = NoRunId
2583
+ trait SignatureCachingType extends TermType {
2584
+ protected [this ] var mySignature : Signature = _
2585
+ protected [this ] var mySignatureRunId : Int = NoRunId
2592
2586
2593
2587
protected def computeSignature (implicit ctx : Context ): Signature
2594
2588
2589
+ final override def signature (implicit ctx : Context ): Signature = {
2590
+ if (ctx.runId != mySignatureRunId) {
2591
+ mySignature = computeSignature
2592
+ if (! mySignature.isUnderDefined) mySignatureRunId = ctx.runId
2593
+ }
2594
+ mySignature
2595
+ }
2596
+ }
2597
+
2598
+ trait MethodicType extends SignatureCachingType {
2595
2599
protected def resultSignature (implicit ctx : Context ) = try resultType match {
2596
2600
case rtp : MethodicType => rtp.signature
2597
2601
case tp =>
@@ -2603,14 +2607,6 @@ object Types {
2603
2607
println(i " failure while taking result signature of $this: $resultType" )
2604
2608
throw ex
2605
2609
}
2606
-
2607
- final override def signature (implicit ctx : Context ): Signature = {
2608
- if (ctx.runId != mySignatureRunId) {
2609
- mySignature = computeSignature
2610
- if (! mySignature.isUnderDefined) mySignatureRunId = ctx.runId
2611
- }
2612
- mySignature
2613
- }
2614
2610
}
2615
2611
2616
2612
/** A by-name parameter type of the form `=> T`, or the type of a method with no parameter list. */
0 commit comments