scalamacros / paradise

(No longer actively maintained.)
http://scalamacros.org/
BSD 3-Clause "New" or "Revised" License
158 stars 53 forks source link

equalsStructure is incorrect in some cases #80

Open aishfenton opened 8 years ago

aishfenton commented 8 years ago

Annotations cause equalsStructure to return false

q"@enum object Test" equalsStructure(q"@enum object Test")
res1: Boolean = false

Whereas this works as expected.

q"object Test" equalsStructure(q"object Test")
res1: Boolean = true

Also while loops seem to have the same issue, raised in a SO question here

xeno-by commented 8 years ago

Thanks for the report! I'll try to find time to look into this.

In the meanwhile, consider using showRaw since it is more reliable. You will probably have to postprocess synthetic names, because some language constructs like while do gensym, but personally I find showRaw more reliable.

Example of how while works:

scala> q"while (true) {}"
res5: reflect.runtime.universe.LabelDef =
while$1(){
  if (true)
    {
      ();
      while$1()
    }
  else
    ()
}
aishfenton commented 8 years ago

Thanks Xeno. Can confirm showRaw is working better for me.