Skip to content

Commit 9a86612

Browse files
oderskyallanrenucci
authored andcommitted
Fix #3633: Inline trees can be pure
Need to be handled like blocks for determining their purity.
1 parent e773e7b commit 9a86612

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
372372
exprPurity(expr)
373373
case Block(stats, expr) =>
374374
minOf(exprPurity(expr), stats.map(statPurity))
375+
case Inlined(_, bindings, expr) =>
376+
minOf(exprPurity(expr), bindings.map(statPurity))
375377
case NamedArg(_, expr) =>
376378
exprPurity(expr)
377379
case _ =>

tests/pos/i3633.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class Test {
2+
inline def foo = 1
3+
def test = -foo
4+
}

0 commit comments

Comments
 (0)