Conversation
This implementation is designed to be more robust: - Excluded type members are supported without rewriting code generated by a macro. - Constraints are expressed without creating a Captured type member. This makes it possible to only use a blackbox macro.
jvican
left a comment
There was a problem hiding this comment.
Yeah, I like the fact that the brittle interaction between excluded and captured disappears. I ran into some issues two months ago. Most of the simplification is already done in my impl, especifically the bits to detect non captured variables. I put some references in the comments 😄. Thanks for showing this, I'll try to create explicit conversions for spores with Excluded types inspiring me in this prototype!
| }) | ||
|
|
||
| def symbolNotCaptured(sym: Symbol): Boolean = | ||
| sym.isStatic || ownerChainContains(sym, fun.symbol) |
There was a problem hiding this comment.
Classes are considered static as well. Yes, isStatic does not work as the reflect docs advertise. I ended up doing this checks https://github.com/scalacenter/spores/blob/master/core/src/main/scala/scala/spores/SporeAnalysis.scala#L117.
There was a problem hiding this comment.
BTW, classes do not fail in neg tests because the toolbox wraps them in an object (and a method), and therefore the true meaning of isStatic (as top-level) does not hold.
| var captured: List[Symbol] = List() | ||
| val traverser = new Traverser { | ||
| override def traverse(tree: Tree): Unit = tree match { | ||
| case id: Ident => |
This implementation is designed to be more robust:
generated by a macro.
member. This makes it possible to only use a blackbox macro.