Skip to content

Commit b2ae710

Browse files
committed
Do widening directly in isErroneous
1 parent 47a270d commit b2ae710

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,9 @@ object Types {
284284
/** Is this type produced as a repair for an error? */
285285
final def isError(implicit ctx: Context): Boolean = stripTypeVar.isInstanceOf[ErrorType]
286286

287-
/** Is some part of this type produced as a repair for an error? */
288-
def isErroneous(implicit ctx: Context): Boolean = existsPart(_.isError, forceLazy = false)
287+
/** Is some part of the widened version of this type produced as a repair for an error? */
288+
def isErroneous(implicit ctx: Context): Boolean =
289+
widen.existsPart(_.isError, forceLazy = false)
289290

290291
/** Does the type carry an annotation that is an instance of `cls`? */
291292
@tailrec final def hasAnnotation(cls: ClassSymbol)(implicit ctx: Context): Boolean = stripTypeVar match {

compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ object ProtoTypes {
367367
def isDropped: Boolean = state.toDrop
368368

369369
override def isErroneous(implicit ctx: Context): Boolean =
370-
state.typedArgs.tpes.exists(_.widen.isErroneous)
370+
state.typedArgs.tpes.exists(_.isErroneous)
371371

372372
override def toString: String = s"FunProto(${args mkString ","} => $resultType)"
373373

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ class Typer extends Namer
735735
val ptDefined = isFullyDefined(pt, ForceDegree.none)
736736
if (ptDefined && !(avoidingType <:< pt)) avoidingType = pt
737737
val tree1 = ascribeType(tree, avoidingType)
738-
assert(ptDefined || noLeaks(tree1) || tree1.tpe.widen.isErroneous,
738+
assert(ptDefined || noLeaks(tree1) || tree1.tpe.isErroneous,
739739
// `ptDefined` needed because of special case of anonymous classes
740740
i"leak: ${escapingRefs(tree1, localSyms).toList}%, % in $tree1")
741741
tree1
@@ -2897,7 +2897,7 @@ class Typer extends Namer
28972897
}
28982898

28992899
private def checkStatementPurity(tree: tpd.Tree)(original: untpd.Tree, exprOwner: Symbol)(implicit ctx: Context): Unit = {
2900-
if (!tree.tpe.widen.isErroneous && !ctx.isAfterTyper && isPureExpr(tree) &&
2900+
if (!tree.tpe.isErroneous && !ctx.isAfterTyper && isPureExpr(tree) &&
29012901
!tree.tpe.isRef(defn.UnitClass) && !isSelfOrSuperConstrCall(tree))
29022902
ctx.warning(PureExpressionInStatementPosition(original, exprOwner), original.sourcePos)
29032903
}

0 commit comments

Comments
 (0)