@@ -70,10 +70,6 @@ object Inliner {
70
70
*/
71
71
def inlineCall (tree : Tree )(implicit ctx : Context ): Tree = {
72
72
if (tree.symbol == defn.CompiletimeTesting_typeChecks ) return Intrinsics .typeChecks(tree)
73
- if tree.symbol.is(Macro ) && tree.symbol.isDefinedInCurrentRun then
74
- if ctx.compilationUnit.source.file == tree.symbol.associatedFile then
75
- ctx.error(" Cannot call macro defined in the same source file" , tree.sourcePos)
76
- ctx.compilationUnit.suspend()
77
73
78
74
/** Set the position of all trees logically contained in the expansion of
79
75
* inlined call `call` to the position of `call`. This transform is necessary
@@ -1241,59 +1237,17 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
1241
1237
assert(level == 0 )
1242
1238
val inlinedFrom = enclosingInlineds.last
1243
1239
val ctx1 = tastyreflect.MacroExpansion .context(inlinedFrom)
1240
+ val evaluatedSplice = Splicer .splice(body, inlinedFrom.sourcePos, MacroClassLoader .fromContext)(ctx1)
1244
1241
1245
- val dependencies = macroDependencies(body)
1246
-
1247
- if (dependencies.nonEmpty) {
1248
- var location = inlinedFrom.symbol
1249
- if (location.isLocalDummy) location = location.owner
1250
-
1251
- val msg =
1252
- em """ Failed to expand macro. This macro depends on an implementation that is defined in the same project and not yet compiled.
1253
- |In particular ${inlinedFrom.symbol} depends on ${dependencies.map(_.show).mkString(" , " )}.
1254
- |
1255
- |Moving ${dependencies.map(_.show).mkString(" , " )} to a different project would fix this.
1256
- | """ .stripMargin
1257
- ctx.error(msg, inlinedFrom.sourcePos)
1258
- EmptyTree
1259
- }
1260
- else {
1261
- val evaluatedSplice = Splicer .splice(body, inlinedFrom.sourcePos, MacroClassLoader .fromContext)(ctx1)
1262
-
1263
- val inlinedNormailizer = new TreeMap {
1264
- override def transform (tree : tpd.Tree )(implicit ctx : Context ): tpd.Tree = tree match {
1265
- case Inlined (EmptyTree , Nil , expr) if enclosingInlineds.isEmpty => transform(expr)
1266
- case _ => super .transform(tree)
1267
- }
1242
+ val inlinedNormailizer = new TreeMap {
1243
+ override def transform (tree : tpd.Tree )(implicit ctx : Context ): tpd.Tree = tree match {
1244
+ case Inlined (EmptyTree , Nil , expr) if enclosingInlineds.isEmpty => transform(expr)
1245
+ case _ => super .transform(tree)
1268
1246
}
1269
- val normalizedSplice = inlinedNormailizer.transform(evaluatedSplice)
1270
- if (normalizedSplice.isEmpty) normalizedSplice
1271
- else normalizedSplice.withSpan(span)
1272
1247
}
1248
+ val normalizedSplice = inlinedNormailizer.transform(evaluatedSplice)
1249
+ if (normalizedSplice.isEmpty) normalizedSplice
1250
+ else normalizedSplice.withSpan(span)
1273
1251
}
1274
-
1275
- /** Return the set of symbols that are refered at level -1 by the tree and defined in the current run.
1276
- * This corresponds to the symbols that will need to be interpreted.
1277
- */
1278
- private def macroDependencies (tree : Tree )(implicit ctx : Context ) =
1279
- new TreeAccumulator [Set [Symbol ]] {
1280
- private [this ] var level = - 1
1281
- override def apply (syms : Set [Symbol ], tree : tpd.Tree )(implicit ctx : Context ): Set [Symbol ] =
1282
- if (level != - 1 ) foldOver(syms, tree)
1283
- else tree match {
1284
- case tree : RefTree if level == - 1 && tree.symbol.isDefinedInCurrentRun && ! tree.symbol.isLocal =>
1285
- foldOver(syms + tree.symbol, tree)
1286
- case Quoted (body) =>
1287
- level += 1
1288
- try apply(syms, body)
1289
- finally level -= 1
1290
- case Spliced (body) =>
1291
- level -= 1
1292
- try apply(syms, body)
1293
- finally level += 1
1294
- case _ =>
1295
- foldOver(syms, tree)
1296
- }
1297
- }.apply(Set .empty, tree)
1298
1252
}
1299
1253
0 commit comments