@@ -111,33 +111,37 @@ object Types {
111
111
*/
112
112
def isProvisional (using Context ): Boolean = mightBeProvisional && testProvisional
113
113
114
- private def testProvisional (using Context ) = {
115
- val accu = new TypeAccumulator [Boolean ] {
116
- override def apply (x : Boolean , t : Type ) =
117
- x || t.mightBeProvisional && {
118
- t.mightBeProvisional = t match {
119
- case t : TypeVar =>
120
- ! t.inst.exists || apply(x, t.inst)
121
- case t : TypeRef =>
114
+ private def testProvisional (using Context ): Boolean =
115
+ def test (t : Type , theAcc : TypeAccumulator [Boolean ]): Boolean =
116
+ if t.mightBeProvisional then
117
+ t.mightBeProvisional = t match
118
+ case t : TypeRef =>
119
+ ! t.currentSymbol.isStatic && {
122
120
(t : Type ).mightBeProvisional = false // break cycles
123
- t.symbol.is(Provisional ) ||
124
- apply(x, t.prefix) || {
125
- t.info match {
126
- case info : AliasingBounds => apply(x, info.alias)
127
- case TypeBounds (lo, hi) => apply(apply(x, lo), hi )
121
+ t.symbol.is(Provisional )
122
+ || test( t.prefix, theAcc)
123
+ || t.info. match
124
+ case info : AliasingBounds => test( info.alias, theAcc )
125
+ case TypeBounds (lo, hi) => test(lo, theAcc) || test(hi, theAcc )
128
126
case _ => false
129
- }
130
- }
131
- case t : LazyRef =>
132
- ! t.completed || apply(x, t.ref)
133
- case _ =>
134
- foldOver(x, t)
135
- }
136
- t.mightBeProvisional
137
- }
138
- }
139
- accu.apply(false , this )
140
- }
127
+ }
128
+ case t : TermRef =>
129
+ ! t.currentSymbol.isStatic && test(t.prefix, theAcc)
130
+ case t : TypeVar =>
131
+ ! t.inst.exists || test(t.inst, theAcc)
132
+ case t : LazyRef =>
133
+ ! t.completed || test(t.ref, theAcc)
134
+ case _ =>
135
+ val acc =
136
+ if theAcc != null then theAcc
137
+ else new TypeAccumulator [Boolean ]:
138
+ override def apply (x : Boolean , t : Type ) = x || test(t, this )
139
+ acc.foldOver(false , t)
140
+ end if
141
+ t.mightBeProvisional
142
+ end test
143
+ test(this , null )
144
+ end testProvisional
141
145
142
146
/** Is this type different from NoType? */
143
147
final def exists : Boolean = this .ne(NoType )
0 commit comments