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 {
284
284
/** Is this type produced as a repair for an error? */
285
285
final def isError (implicit ctx : Context ): Boolean = stripTypeVar.isInstanceOf [ErrorType ]
286
286
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 )
289
290
290
291
/** Does the type carry an annotation that is an instance of `cls`? */
291
292
@ 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 {
367
367
def isDropped : Boolean = state.toDrop
368
368
369
369
override def isErroneous (implicit ctx : Context ): Boolean =
370
- state.typedArgs.tpes.exists(_.widen. isErroneous)
370
+ state.typedArgs.tpes.exists(_.isErroneous)
371
371
372
372
override def toString : String = s " FunProto( ${args mkString " ," } => $resultType) "
373
373
Original file line number Diff line number Diff line change @@ -735,7 +735,7 @@ class Typer extends Namer
735
735
val ptDefined = isFullyDefined(pt, ForceDegree .none)
736
736
if (ptDefined && ! (avoidingType <:< pt)) avoidingType = pt
737
737
val tree1 = ascribeType(tree, avoidingType)
738
- assert(ptDefined || noLeaks(tree1) || tree1.tpe.widen. isErroneous,
738
+ assert(ptDefined || noLeaks(tree1) || tree1.tpe.isErroneous,
739
739
// `ptDefined` needed because of special case of anonymous classes
740
740
i " leak: ${escapingRefs(tree1, localSyms).toList}%, % in $tree1" )
741
741
tree1
@@ -2897,7 +2897,8 @@ class Typer extends Namer
2897
2897
}
2898
2898
2899
2899
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))
2901
2902
ctx.warning(PureExpressionInStatementPosition (original, exprOwner), original.sourcePos)
2902
2903
}
2903
2904
}
Original file line number Diff line number Diff line change @@ -25,4 +25,8 @@ object Test {
25
25
2 // error: pure expression does nothing in statement position
26
26
27
27
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
28
32
}
You can’t perform that action at this time.
0 commit comments