@@ -154,7 +154,7 @@ object TypeTestsCasts {
154
154
case tp2 : RefinedType => recur(X , tp2.parent) && TypeComparer .hasMatchingMember(tp2.refinedName, X , tp2)
155
155
case tp2 : RecType => recur(X , tp2.parent)
156
156
case _
157
- if P .classSymbol.isLocal && P .classSymbol.isInaccessibleChildOf( X .classSymbol ) => // 8
157
+ if P .classSymbol.isLocal && foundClasses( X , Nil ).exists( P .classSymbol.isInaccessibleChildOf) => // 8
158
158
false
159
159
case _ => true
160
160
})
@@ -178,15 +178,6 @@ object TypeTestsCasts {
178
178
def derivedTree (expr1 : Tree , sym : Symbol , tp : Type ) =
179
179
cpy.TypeApply (tree)(expr1.select(sym).withSpan(expr.span), List (TypeTree (tp)))
180
180
181
- def effectiveClass (tp : Type ): Symbol =
182
- if tp.isRef(defn.PairClass ) then effectiveClass(erasure(tp))
183
- else if tp.isRef(defn.AnyValClass ) then defn.AnyClass
184
- else tp.classSymbol
185
-
186
- def foundClasses (tp : Type , acc : List [Symbol ]): List [Symbol ] = tp.dealias match
187
- case OrType (tp1, tp2) => foundClasses(tp2, foundClasses(tp1, acc))
188
- case _ => effectiveClass(tp) :: acc
189
-
190
181
def inMatch =
191
182
tree.fun.symbol == defn.Any_typeTest || // new scheme
192
183
expr.symbol.is(Case ) // old scheme
@@ -376,4 +367,13 @@ object TypeTestsCasts {
376
367
}
377
368
interceptWith(expr)
378
369
}
370
+
371
+ private def effectiveClass (tp : Type )(using Context ): Symbol =
372
+ if tp.isRef(defn.PairClass ) then effectiveClass(erasure(tp))
373
+ else if tp.isRef(defn.AnyValClass ) then defn.AnyClass
374
+ else tp.classSymbol
375
+
376
+ private def foundClasses (tp : Type , acc : List [Symbol ])(using Context ): List [Symbol ] = tp.dealias match
377
+ case OrType (tp1, tp2) => foundClasses(tp2, foundClasses(tp1, acc))
378
+ case _ => effectiveClass(tp) :: acc
379
379
}
0 commit comments