@@ -154,7 +154,7 @@ object TypeTestsCasts {
154154 case tp2 : RefinedType => recur(X , tp2.parent) && TypeComparer .hasMatchingMember(tp2.refinedName, X , tp2)
155155 case tp2 : RecType => recur(X , tp2.parent)
156156 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
158158 false
159159 case _ => true
160160 })
@@ -178,15 +178,6 @@ object TypeTestsCasts {
178178 def derivedTree (expr1 : Tree , sym : Symbol , tp : Type ) =
179179 cpy.TypeApply (tree)(expr1.select(sym).withSpan(expr.span), List (TypeTree (tp)))
180180
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-
190181 def inMatch =
191182 tree.fun.symbol == defn.Any_typeTest || // new scheme
192183 expr.symbol.is(Case ) // old scheme
@@ -376,4 +367,13 @@ object TypeTestsCasts {
376367 }
377368 interceptWith(expr)
378369 }
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
379379}
0 commit comments