File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed
compiler/src/dotty/tools/dotc/typer
tests/neg-custom-args/fatal-warnings Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -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.widen.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