[macros, reflection] Any simple way to compare to Trees for structural equality?

51 views
Skip to first unread message

Dmitry Grigoriev

unread,
Jul 8, 2014, 1:59:02 PM7/8/14
to scala...@googlegroups.com
Hi all. Subj. E.g.:


scala> import reflect.runtime.universe._
import reflect.runtime.universe._

scala> val a = 1
a: Int = 1

scala> val b = 2
b: Int = 2

scala> val t1 = reify { a + b }.tree
t1: reflect.runtime.universe.Tree = $read.a.$plus($read.b)

scala> val t2 = reify { a + b }.tree
t2: reflect.runtime.universe.Tree = $read.a.$plus($read.b)

scala> t1 == t2
res0: Boolean = false


But I'd like to see res0 = true.

Eugene Burmako

unread,
Jul 8, 2014, 2:01:21 PM7/8/14
to Dmitry Grigoriev, scala-user
scala> t1.equalsStructure(t2)
res1: Boolean = true



--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dmitry Grigoriev

unread,
Jul 8, 2014, 2:06:16 PM7/8/14
to scala...@googlegroups.com, ma...@dimgel.ru
Thanks. :)
Reply all
Reply to author
Forward
0 new messages