Skip to content

Commit 7709848

Browse files
committed
Ignore type parameters in macro runtime dependencies
The `macroDependencies` method collects all the definitions that are required to interpret the contents of the splice (using JVM-reflection). We do not care about type parameters because those are erased and the interpreter emulates erased semantics. Fixes #12498
1 parent 7d6d42f commit 7709848

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

compiler/src/dotty/tools/dotc/inlines/Inliner.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,8 @@ class Inliner(val call: tpd.Tree)(using Context):
10621062
level -= 1
10631063
try apply(syms, body)
10641064
finally level += 1
1065+
case TypeApply(fun, _) if level == -1 =>
1066+
apply(syms, fun)
10651067
case _ =>
10661068
foldOver(syms, tree)
10671069
}

tests/pos-macros/i12498/Macro_1.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import scala.quoted.*
2+
3+
class Wrapper[T](t: T):
4+
inline def showType: String = ${ Wrapper.showTypeImpl[T]}
5+
6+
object Wrapper:
7+
def showTypeImpl[U](using Quotes): Expr[String] = Expr("foo")

tests/pos-macros/i12498/Test_2.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Person
2+
3+
def test = Wrapper(new Person).showType

0 commit comments

Comments
 (0)