Skip to content

Commit a5384cf

Browse files
nicolasstuckiKordyjan
authored andcommitted
Handle macro dependencies through class of this
Fixes #18393 [Cherry-picked 671f755]
1 parent 89e65e9 commit a5384cf

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-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
@@ -1067,6 +1067,8 @@ class Inliner(val call: tpd.Tree)(using Context):
10671067
tree match {
10681068
case tree: RefTree if tree.isTerm && level == -1 && tree.symbol.isDefinedInCurrentRun && !tree.symbol.isLocal =>
10691069
foldOver(tree.symbol :: syms, tree)
1070+
case _: This if level == -1 && tree.symbol.isDefinedInCurrentRun =>
1071+
tree.symbol :: syms
10701072
case _: TypTree => syms
10711073
case _ => foldOver(syms, tree)
10721074
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package user
2+
3+
import defn.Macro
4+
5+
object Inline extends Macro {
6+
inline def callMacro(): Int =
7+
${ this.impl() }
8+
}

tests/pos-macros/i18393/Macro_1.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package defn
2+
3+
import scala.quoted.*
4+
5+
abstract class Macro {
6+
def impl()(using Quotes): Expr[Int] = '{1}
7+
}

tests/pos-macros/i18393/Test_2.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package user
2+
3+
object Test {
4+
Inline.callMacro()
5+
}

0 commit comments

Comments
 (0)