From 9a86612f68a8fb7e5a973f35f3fd58663f290514 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 12 Dec 2017 08:52:46 +0100 Subject: [PATCH] Fix #3633: Inline trees can be pure Need to be handled like blocks for determining their purity. --- compiler/src/dotty/tools/dotc/ast/TreeInfo.scala | 2 ++ tests/pos/i3633.scala | 4 ++++ 2 files changed, 6 insertions(+) create mode 100644 tests/pos/i3633.scala diff --git a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala index 77e38410990f..da8759a5f5fc 100644 --- a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala +++ b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala @@ -372,6 +372,8 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] => exprPurity(expr) case Block(stats, expr) => minOf(exprPurity(expr), stats.map(statPurity)) + case Inlined(_, bindings, expr) => + minOf(exprPurity(expr), bindings.map(statPurity)) case NamedArg(_, expr) => exprPurity(expr) case _ => diff --git a/tests/pos/i3633.scala b/tests/pos/i3633.scala new file mode 100644 index 000000000000..a021e9ca077f --- /dev/null +++ b/tests/pos/i3633.scala @@ -0,0 +1,4 @@ +class Test { + inline def foo = 1 + def test = -foo +}