Skip to content

Commit

Permalink
Ignore type parameters in macro runtime dependencies
Browse files Browse the repository at this point in the history
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 scala#12498
  • Loading branch information
nicolasstucki committed Jun 27, 2022
1 parent f92ab11 commit 306f55b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/typer/Inliner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1896,6 +1896,8 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
level -= 1
try apply(syms, body)
finally level += 1
case TypeApply(fun, _) =>
apply(syms, fun)
case _ =>
foldOver(syms, tree)
}
Expand Down
7 changes: 7 additions & 0 deletions tests/pos-macros/i12498/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -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")
3 changes: 3 additions & 0 deletions tests/pos-macros/i12498/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Person

def test = Wrapper(new Person).showType

0 comments on commit 306f55b

Please sign in to comment.