@@ -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,35 +1237,25 @@ 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)
1244
-
1245
1240
val dependencies = macroDependencies(body)
1246
1241
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)
1242
+ if dependencies.nonEmpty then
1243
+ for sym <- dependencies do
1244
+ if ctx.compilationUnit.source.file == sym.associatedFile then
1245
+ ctx.error(em " Cannot call macro $sym defined in the same source file " , body.sourcePos)
1246
+ ctx.compilationUnit.suspend() // this throws a SuspendException
1262
1247
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
- }
1248
+ val evaluatedSplice = Splicer .splice(body, inlinedFrom.sourcePos, MacroClassLoader .fromContext)(ctx1)
1249
+
1250
+ val inlinedNormailizer = new TreeMap {
1251
+ override def transform (tree : tpd.Tree )(implicit ctx : Context ): tpd.Tree = tree match {
1252
+ case Inlined (EmptyTree , Nil , expr) if enclosingInlineds.isEmpty => transform(expr)
1253
+ case _ => super .transform(tree)
1268
1254
}
1269
- val normalizedSplice = inlinedNormailizer.transform(evaluatedSplice)
1270
- if (normalizedSplice.isEmpty) normalizedSplice
1271
- else normalizedSplice.withSpan(span)
1272
1255
}
1256
+ val normalizedSplice = inlinedNormailizer.transform(evaluatedSplice)
1257
+ if (normalizedSplice.isEmpty) normalizedSplice
1258
+ else normalizedSplice.withSpan(span)
1273
1259
}
1274
1260
1275
1261
/** Return the set of symbols that are refered at level -1 by the tree and defined in the current run.
0 commit comments