djspiewak/anti-xml

asInstanceOf in LinkedOrderPreservingMap throws ClassCastException

Opened this issue · 0 comments

Hi,

  def syncElems(e1: Elem, e2: Elem): Elem = {
    val fullAttrs = e1.attrs.filterNot(_._2.isEmpty)
    val newAttrs = e2.attrs.filterNot(
      at => fullAttrs.keys exists (at._1 == _)).filter(
      at => e1.attrs.keys exists (at._1 == _))
    e1.copy(attrs = fullAttrs ++: newAttrs)
  }

throws a CastClassException while

  def syncElems(e1: Elem, e2: Elem): Elem = {
    val fullAttrs = e1.attrs.filterNot(_._2.isEmpty)
    e1.copy(attrs = fullAttrs ++: e2.attrs.filterNot(
      at => fullAttrs.keys exists (at._1 == _)).filter(
      at => e1.attrs.keys exists (at._1 == _)))
  }

works fine.

Thanks,

G.N