File tree 4 files changed +34
-6
lines changed
compiler/src/dotty/tools/dotc/inlines 4 files changed +34
-6
lines changed Original file line number Diff line number Diff line change @@ -1065,15 +1065,23 @@ class Inliner(val call: tpd.Tree)(using Context):
1065
1065
* This corresponds to the symbols that will need to be interpreted.
1066
1066
*/
1067
1067
private def macroDependencies (tree : Tree )(using Context ) =
1068
+ val typeAccumulator = new TypeAccumulator [List [Symbol ]] {
1069
+ def apply (x : List [Symbol ], tp : Type ): List [Symbol ] = tp match
1070
+ case tp : TermRef =>
1071
+ if tp.symbol.isDefinedInCurrentRun then foldOver(tp.symbol :: x, tp)
1072
+ else foldOver(x, tp)
1073
+ case tp : ThisType if tp.typeSymbol.isDefinedInCurrentRun =>
1074
+ foldOver(tp.typeSymbol :: x, tp)
1075
+ case _ =>
1076
+ x
1077
+ }
1068
1078
new TreeAccumulator [List [Symbol ]] {
1069
1079
override def apply (syms : List [Symbol ], tree : tpd.Tree )(using Context ): List [Symbol ] =
1070
- tree match {
1071
- case tree : RefTree if tree.isTerm && level == - 1 && tree.symbol.isDefinedInCurrentRun && ! tree.symbol.isLocal =>
1072
- foldOver(tree.symbol :: syms, tree)
1073
- case _ : This if level == - 1 && tree.symbol.isDefinedInCurrentRun =>
1074
- tree.symbol :: syms
1080
+ tree match
1081
+ case tree : RefTree if tree.isTerm && level == - 1 && ! tree.symbol.isLocal =>
1082
+ typeAccumulator(syms, tree.tpe)
1075
1083
case _ : TypTree => syms
1076
1084
case _ => foldOver(syms, tree)
1077
- }
1078
1085
}.apply(Nil , tree)
1086
+
1079
1087
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