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