Skip to content

Commit 5bc830b

Browse files
committed
Fix #4515: Synthesize implicit type tags in transparent methods
1 parent 2e834ea commit 5bc830b

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,8 @@ trait Implicits { self: Typer =>
620620
val tag = bindFreeVars(arg)
621621
if (bindFreeVars.ok) ref(defn.QuotedType_apply).appliedToType(tag)
622622
else EmptyTree
623+
case arg :: Nil if ctx.inTransparentMethod =>
624+
ref(defn.QuotedType_apply).appliedToType(arg)
623625
case _ =>
624626
EmptyTree
625627
}

tests/run/i4515/Macro_1.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
object Macro {
3+
transparent def foo[X](x: X): Unit = ~fooImpl('(x))
4+
def fooImpl[X: quoted.Type](x: quoted.Expr[X]): quoted.Expr[Unit] = '()
5+
}

tests/run/i4515/Test_2.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
object Test {
3+
def main(args: Array[String]): Unit = {
4+
Macro.foo(4)
5+
}
6+
}

0 commit comments

Comments
 (0)