You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix for macro annotation that resolves macro-based implicit crashing the compiler (#20353)
When (1) macro-annotating a class or object nested in another class or
object and (2) the annotation macro tries to summon an implicit value
using `Implicits.search` and (3) the implicit search needs to expand a
`given` macro, the compiler crashes with:
```
Failed to evaluate macro.
Caused by class dotty.tools.dotc.CompilationUnit$SuspendException
```
I found that the reason for the crash is
[`macroDependencies`](https://github.com/scala/scala3/blob/3.4.1/compiler/src/dotty/tools/dotc/inlines/Inliner.scala#L1067)
returning locally defined variables, which, I believe, it should not. In
particular it returns a list containing `$anonfun` for trees of the
following shape that appear when resolving implicit macros:
```
{
def $anonfun(using contextual$1: scala.quoted.Quotes): scala.quoted.Expr[<type for implicit search>] =
<given macro for implicit value>(contextual$1)
closure($anonfun)
}
```
This PR skips over such `Closure` nodes, which should be the correct
behavior. Not sure if there are other cases that `macroDependencies`
handles incorrectly and that should be fixed ...
0 commit comments