File tree Expand file tree Collapse file tree 4 files changed +34
-6
lines changed
compiler/src/dotty/tools/dotc/inlines Expand file tree Collapse file tree 4 files changed +34
-6
lines changed Original file line number Diff line number Diff line change @@ -1062,15 +1062,23 @@ class Inliner(val call: tpd.Tree)(using Context):
1062
1062
* This corresponds to the symbols that will need to be interpreted.
1063
1063
*/
1064
1064
private def macroDependencies (tree : Tree )(using Context ) =
1065
+ val typeAccumulator = new TypeAccumulator [List [Symbol ]] {
1066
+ def apply (x : List [Symbol ], tp : Type ): List [Symbol ] = tp match
1067
+ case tp : TermRef =>
1068
+ if tp.symbol.isDefinedInCurrentRun then foldOver(tp.symbol :: x, tp)
1069
+ else foldOver(x, tp)
1070
+ case tp : ThisType if tp.typeSymbol.isDefinedInCurrentRun =>
1071
+ foldOver(tp.typeSymbol :: x, tp)
1072
+ case _ =>
1073
+ x
1074
+ }
1065
1075
new TreeAccumulator [List [Symbol ]] {
1066
1076
override def apply (syms : List [Symbol ], tree : tpd.Tree )(using Context ): List [Symbol ] =
1067
- tree match {
1068
- case tree : RefTree if tree.isTerm && level == - 1 && tree.symbol.isDefinedInCurrentRun && ! tree.symbol.isLocal =>
1069
- foldOver(tree.symbol :: syms, tree)
1070
- case _ : This if level == - 1 && tree.symbol.isDefinedInCurrentRun =>
1071
- tree.symbol :: syms
1077
+ tree match
1078
+ case tree : RefTree if tree.isTerm && level == - 1 && ! tree.symbol.isLocal =>
1079
+ typeAccumulator(syms, tree.tpe)
1072
1080
case _ : TypTree => syms
1073
1081
case _ => foldOver(syms, tree)
1074
- }
1075
1082
}.apply(Nil , tree)
1083
+
1076
1084
end Inliner
Original file line number Diff line number Diff line change
1
+ package user
2
+
3
+ import defn .Macro
4
+
5
+ object Inline extends Macro {
6
+ inline def callMacro (): Int =
7
+ $ { impl() }
8
+ }
Original file line number Diff line number Diff line change
1
+ package defn
2
+
3
+ import scala .quoted .*
4
+
5
+ abstract class Macro {
6
+ def impl ()(using Quotes ): Expr [Int ] = ' {1 }
7
+ }
Original file line number Diff line number Diff line change
1
+ package user
2
+
3
+ object Test {
4
+ Inline .callMacro()
5
+ }
You can’t perform that action at this time.
0 commit comments