Skip to content

Commit 4a5ab5a

Browse files
committed
Address review: code refactoring
1 parent fb672e5 commit 4a5ab5a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ object TypeTestsCasts {
9191
}.apply(tp)
9292

9393
/** Returns true if the type arguments of `P` can be determined from `X` */
94-
def typeArgsTrivial(X: Type, P: AppliedType)(implicit ctx: Context) = {
94+
def typeArgsTrivial(X: Type, P: AppliedType)(using Context) = inContext(ctx.fresh.setExploreTyperState().setFreshGADTBounds) {
9595
val AppliedType(tycon, _) = P
9696

9797
def underlyingLambda(tp: Type): TypeLambda = tp.ensureLambdaSub match {
@@ -146,10 +146,11 @@ object TypeTestsCasts {
146146
recur(tp1, P) && recur(tp2, P)
147147
case _ =>
148148
// always false test warnings are emitted elsewhere
149-
X.classSymbol.exists && P.classSymbol.exists && !X.classSymbol.asClass.mayHaveCommonChild(P.classSymbol.asClass) ||
149+
X.classSymbol.exists && P.classSymbol.exists &&
150+
!X.classSymbol.asClass.mayHaveCommonChild(P.classSymbol.asClass) ||
150151
// first try without striping type parameters for performance
151-
typeArgsTrivial(X, tpe)(ctx.fresh.setNewTyperState().setFreshGADTBounds) ||
152-
typeArgsTrivial(stripTypeParam(X), tpe)(ctx.fresh.setNewTyperState().setFreshGADTBounds)
152+
typeArgsTrivial(X, tpe) ||
153+
typeArgsTrivial(stripTypeParam(X), tpe)
153154
}
154155
case AndType(tp1, tp2) => recur(X, tp1) && recur(X, tp2)
155156
case OrType(tp1, tp2) => recur(X, tp1) && recur(X, tp2)

0 commit comments

Comments
 (0)