Skip to content

Commit

Permalink
Refine code
Browse files Browse the repository at this point in the history
  • Loading branch information
liufengyun committed May 2, 2023
1 parent 5344b06 commit 879ebde
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ object TypeTestsCasts {

/** Whether the check X.isInstanceOf[P] is definitely false? */
def isCheckDefinitelyFalse(X: Type, P: Type)(using Context): Boolean = trace(s"isCheckDefinitelyFalse(${X.show}, ${P.show})") {
X.dealias match
X.widenDealias match
case AndType(x1, x2) =>
isCheckDefinitelyFalse(x1, P) || isCheckDefinitelyFalse(x2, P)

case x =>
P.dealias match
P.widenDealias match
case AndType(p1, p2) =>
isCheckDefinitelyFalse(x, p1) || isCheckDefinitelyFalse(x, p2)

Expand All @@ -154,8 +154,8 @@ object TypeTestsCasts {
xs.forall(x => isCheckDefinitelyFalse(x, p))
else
if x.typeSymbol.isClass && p.typeSymbol.isClass then
val xClass = effectiveClass(x.widen)
val pClass = effectiveClass(p.widen)
val xClass = effectiveClass(x)
val pClass = effectiveClass(p)

!xClass.derivesFrom(pClass)
&& (xClass.is(Final) || pClass.is(Final) || !xClass.is(Trait) && !pClass.is(Trait))
Expand Down

0 comments on commit 879ebde

Please sign in to comment.