File tree 2 files changed +17
-2
lines changed
compiler/src/dotty/tools/dotc/typer
tests/pos-special/fatal-warnings 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -3629,8 +3629,12 @@ class Typer extends Namer
3629
3629
}
3630
3630
3631
3631
private def checkStatementPurity (tree : tpd.Tree )(original : untpd.Tree , exprOwner : Symbol )(using Context ): Unit =
3632
- if (! tree.tpe.isErroneous && ! ctx.isAfterTyper && isPureExpr(tree) &&
3633
- ! tree.tpe.isRef(defn.UnitClass ) && ! isSelfOrSuperConstrCall(tree))
3632
+ if ! tree.tpe.isErroneous
3633
+ && ! ctx.isAfterTyper
3634
+ && isPureExpr(tree)
3635
+ && ! tree.tpe.widenTermRefExpr.isRef(defn.UnitClass )
3636
+ && ! isSelfOrSuperConstrCall(tree)
3637
+ then
3634
3638
report.warning(PureExpressionInStatementPosition (original, exprOwner), original.srcPos)
3635
3639
3636
3640
/** Types the body Scala 2 macro declaration `def f = macro <body>` */
Original file line number Diff line number Diff line change
1
+ object Test {
2
+ extension (x : Int )
3
+ inline def times (inline op : Unit ): Unit = {
4
+ var count = 0
5
+ while count < x do
6
+ op
7
+ count += 1
8
+ }
9
+
10
+ 10 .times { println(" hello" ) }
11
+ }
You can’t perform that action at this time.
0 commit comments