File tree Expand file tree Collapse file tree 4 files changed +11
-5
lines changed
compiler/src/dotty/tools/dotc
tests/neg-custom-args/fatal-warnings Expand file tree Collapse file tree 4 files changed +11
-5
lines changed Original file line number Diff line number Diff 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 {
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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,8 @@ class Typer extends Namer
28972897 }
28982898
28992899 private def checkStatementPurity (tree : tpd.Tree )(original : untpd.Tree , exprOwner : Symbol )(implicit ctx : Context ): Unit = {
2900- if (! ctx.isAfterTyper && isPureExpr(tree) && ! tree.tpe.isRef(defn.UnitClass ) && ! isSelfOrSuperConstrCall(tree))
2900+ if (! tree.tpe.isErroneous && ! ctx.isAfterTyper && isPureExpr(tree) &&
2901+ ! tree.tpe.isRef(defn.UnitClass ) && ! isSelfOrSuperConstrCall(tree))
29012902 ctx.warning(PureExpressionInStatementPosition (original, exprOwner), original.sourcePos)
29022903 }
29032904}
Original file line number Diff line number Diff line change @@ -25,4 +25,8 @@ object Test {
2525 2 // error: pure expression does nothing in statement position
2626
2727 doSideEffects(1 ) // error: pure expression does nothing in statement position
28+
29+ val broken = new IDontExist (" " ) // error // error
30+ broken.foo // no extra error, and no pure expression warning
31+ broken.foo() // same
2832}
You can’t perform that action at this time.
0 commit comments