From 576f7b1a0ad0019e1ea15207e5c6f41cb0abc81c Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 9 Apr 2019 17:25:45 +0200 Subject: [PATCH] Fix checkInlineConformant check for inlined trees We where considering an `Inlined` tree as not conformant even if its contents are conformat. Now we check if the exapnsion is conformant. --- compiler/src/dotty/tools/dotc/transform/Splicer.scala | 2 +- compiler/src/dotty/tools/dotc/typer/Checking.scala | 2 ++ tests/pos/inlined-inline-param.scala | 4 ++++ tests/run-with-compiler/reflect-inline/assert_1.scala | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 tests/pos/inlined-inline-param.scala diff --git a/compiler/src/dotty/tools/dotc/transform/Splicer.scala b/compiler/src/dotty/tools/dotc/transform/Splicer.scala index 704c44f41a1c..3901509a07f1 100644 --- a/compiler/src/dotty/tools/dotc/transform/Splicer.scala +++ b/compiler/src/dotty/tools/dotc/transform/Splicer.scala @@ -356,7 +356,7 @@ object Splicer { interpretTree(expr)(newEnv) case NamedArg(_, arg) => interpretTree(arg) - case Inlined(EmptyTree, Nil, expansion) => interpretTree(expansion) + case Inlined(_, Nil, expansion) => interpretTree(expansion) case Typed(expr, _) => interpretTree(expr) diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala index 9fbdcbbc0606..073200825e16 100644 --- a/compiler/src/dotty/tools/dotc/typer/Checking.scala +++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala @@ -710,6 +710,8 @@ trait Checking { tree match { case Typed(expr, _) => checkInlineConformant(expr, isFinal, what) + case Inlined(_, Nil, expr) => + checkInlineConformant(expr, isFinal, what) case SeqLiteral(elems, _) => elems.foreach(elem => checkInlineConformant(elem, isFinal, what)) case Apply(fn, List(arg)) if defn.WrapArrayMethods().contains(fn.symbol) => diff --git a/tests/pos/inlined-inline-param.scala b/tests/pos/inlined-inline-param.scala new file mode 100644 index 000000000000..14df79b9df98 --- /dev/null +++ b/tests/pos/inlined-inline-param.scala @@ -0,0 +1,4 @@ +class Foo { + inline def foo(inline x: Int): Int = x + def bar: Int = foo(foo(4)) +} diff --git a/tests/run-with-compiler/reflect-inline/assert_1.scala b/tests/run-with-compiler/reflect-inline/assert_1.scala index f653c220e62c..020b7379977b 100644 --- a/tests/run-with-compiler/reflect-inline/assert_1.scala +++ b/tests/run-with-compiler/reflect-inline/assert_1.scala @@ -2,7 +2,7 @@ import scala.quoted._ import scala.tasty._ object api { - inline def (inline x: String) stripMargin <: String = + inline def (inline x: String) stripMargin: String = ${ stripImpl(x) } private def stripImpl(x: String)(implicit refl: Reflection): Expr[String] =