diff --git a/compiler/src/dotty/tools/dotc/inlines/Inliner.scala b/compiler/src/dotty/tools/dotc/inlines/Inliner.scala index a12a2d7fcac5..df573ce1fbdf 100644 --- a/compiler/src/dotty/tools/dotc/inlines/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/inlines/Inliner.scala @@ -1046,9 +1046,9 @@ class Inliner(val call: tpd.Tree)(using Context): new TreeAccumulator[List[Symbol]] { private var level = -1 override def apply(syms: List[Symbol], tree: tpd.Tree)(using Context): List[Symbol] = - if (level != -1) foldOver(syms, tree) + if level != -1 then foldOver(syms, tree) else tree match { - case tree: RefTree if level == -1 && tree.symbol.isDefinedInCurrentRun && !tree.symbol.isLocal => + case tree: RefTree if tree.symbol.isDefinedInCurrentRun && !tree.symbol.isLocal => foldOver(tree.symbol :: syms, tree) case Quoted(body) => level += 1 @@ -1062,6 +1062,8 @@ class Inliner(val call: tpd.Tree)(using Context): level -= 1 try apply(syms, body) finally level += 1 + case TypeApply(fun, _) => + apply(syms, fun) case _ => foldOver(syms, tree) } diff --git a/tests/pos-macros/i12498/Macro_1.scala b/tests/pos-macros/i12498/Macro_1.scala new file mode 100644 index 000000000000..7e24b27f92a1 --- /dev/null +++ b/tests/pos-macros/i12498/Macro_1.scala @@ -0,0 +1,7 @@ +import scala.quoted.* + +class Wrapper[T](t: T): + inline def showType: String = ${ Wrapper.showTypeImpl[T]} + +object Wrapper: + def showTypeImpl[U](using Quotes): Expr[String] = Expr("foo") diff --git a/tests/pos-macros/i12498/Test_2.scala b/tests/pos-macros/i12498/Test_2.scala new file mode 100644 index 000000000000..1c509f3c7a23 --- /dev/null +++ b/tests/pos-macros/i12498/Test_2.scala @@ -0,0 +1,3 @@ +class Person + +def test = Wrapper(new Person).showType diff --git a/tests/pos-macros/i12498a/Macro_1.scala b/tests/pos-macros/i12498a/Macro_1.scala new file mode 100644 index 000000000000..7e24b27f92a1 --- /dev/null +++ b/tests/pos-macros/i12498a/Macro_1.scala @@ -0,0 +1,7 @@ +import scala.quoted.* + +class Wrapper[T](t: T): + inline def showType: String = ${ Wrapper.showTypeImpl[T]} + +object Wrapper: + def showTypeImpl[U](using Quotes): Expr[String] = Expr("foo") diff --git a/tests/pos-macros/i12498a/Test_2.scala b/tests/pos-macros/i12498a/Test_2.scala new file mode 100644 index 000000000000..1c509f3c7a23 --- /dev/null +++ b/tests/pos-macros/i12498a/Test_2.scala @@ -0,0 +1,3 @@ +class Person + +def test = Wrapper(new Person).showType diff --git a/tests/pos-macros/i12498b/Macro_1.scala b/tests/pos-macros/i12498b/Macro_1.scala new file mode 100644 index 000000000000..47a8966699c3 --- /dev/null +++ b/tests/pos-macros/i12498b/Macro_1.scala @@ -0,0 +1,8 @@ +import scala.quoted.* + + +class Wrapper[T](t: T): + inline def nothing: T = ${ Wrapper.nothing : Expr[T] } + +object Wrapper: + def nothing(using Quotes): Expr[Nothing] = '{???} diff --git a/tests/pos-macros/i12498b/Test_2.scala b/tests/pos-macros/i12498b/Test_2.scala new file mode 100644 index 000000000000..de3f23205e2c --- /dev/null +++ b/tests/pos-macros/i12498b/Test_2.scala @@ -0,0 +1,3 @@ +class Person + +def test = Wrapper(new Person).nothing diff --git a/tests/pos-macros/i12498c/Macro_1.scala b/tests/pos-macros/i12498c/Macro_1.scala new file mode 100644 index 000000000000..d50ceca03eef --- /dev/null +++ b/tests/pos-macros/i12498c/Macro_1.scala @@ -0,0 +1,8 @@ +import scala.quoted.* + + +class Wrapper[T](t: T): + inline def emptyList: List[T] = ${ Wrapper.emptyListImpl : Expr[List[T]] } + +object Wrapper: + def emptyListImpl(using Quotes): Expr[List[Nothing]] = Expr(Nil) diff --git a/tests/pos-macros/i12498c/Test_2.scala b/tests/pos-macros/i12498c/Test_2.scala new file mode 100644 index 000000000000..5c41b39b3f85 --- /dev/null +++ b/tests/pos-macros/i12498c/Test_2.scala @@ -0,0 +1,3 @@ +class Person + +def test = Wrapper(new Person).emptyList