Skip to content

Commit 306f55b

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 f92ab11 commit 306f55b

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,6 +1896,8 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
18961896
level -= 1
18971897
try apply(syms, body)
18981898
finally level += 1
1899+
case TypeApply(fun, _) =>
1900+
apply(syms, fun)
18991901
case _ =>
19001902
foldOver(syms, tree)
19011903
}

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)