- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Typed trees not being dropped by erasure
Mon, 2012-01-16, 12:50
Hi,
I found a bit of confusion related to Typed tree nodes. Comment in Trees claims that Typed nodes are being eliminated by erasure:
https://github.com/scala/scala/blob/master/src/library/scala/reflect/api/Trees.scala#L1374
However, if you check erasure it never drops Typed nodes and in one case it introduces a new one:
https://github.com/scala/scala/blob/master/src/compiler/scala/tools/nsc/transform/Erasure.scala#L938
Typed node is being introduced by erasure in a case of upcast.
I'm wondering what would be preferred way to resolve this. Either fixing erasure to really drop Typed nodes and not introduced any new ones or fix the comment in Trees.
Fixing erasure has this advantage that others (genicode, scala+gwt) doesn't need to bother with Typed nodes down the pipeline anymore. However, I don't know if dropping Typed nodes and simply setting tpe in case of upcast is a good idea.
Any advice?
-- Best regards,
Grzegorz Kossakowski
I found a bit of confusion related to Typed tree nodes. Comment in Trees claims that Typed nodes are being eliminated by erasure:
https://github.com/scala/scala/blob/master/src/library/scala/reflect/api/Trees.scala#L1374
However, if you check erasure it never drops Typed nodes and in one case it introduces a new one:
https://github.com/scala/scala/blob/master/src/compiler/scala/tools/nsc/transform/Erasure.scala#L938
Typed node is being introduced by erasure in a case of upcast.
I'm wondering what would be preferred way to resolve this. Either fixing erasure to really drop Typed nodes and not introduced any new ones or fix the comment in Trees.
Fixing erasure has this advantage that others (genicode, scala+gwt) doesn't need to bother with Typed nodes down the pipeline anymore. However, I don't know if dropping Typed nodes and simply setting tpe in case of upcast is a good idea.
Any advice?
-- Best regards,
Grzegorz Kossakowski
On Mon, Jan 16, 2012 at 3:49 AM, Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> wrote:
You can see more introduced after erasure as well (all the way to Cleanup at least) because it's the only way to generate a catch block. Typed isn't always a type ascription, it is also used for type tests. That has to change if we want to eliminate them in erasure.