Aladdin - Scala Bugtracking
[#547] project: compiler priority: low category: bug
submitter assigned to status date submitted
Burak _ _ 2006-03-14 15:12:36.0
subject xml patterns get wrongly translated
code
object Test extends Application {

  <hello/> match { case <hello/> => true; case _ => false; };

}
what happened
if you compile, with -print:transmatch you see that it gets translated all wrongly. The reason seem\
s to be that the XML pattern somehow
is interpreted as being a sequence pattern.
package <empty> {
  final class Test extends java.lang.Object with scala.Application with scala.ScalaObject {
    def <init>(): Test = {
      Test.super.<init>();
      ()
    };
    {
      var temp0: scala.xml.Elem = {
        {
          new scala.xml.Elem.<init>(null, "hello", scala.xml.Null, scala.this.Predef.$scope(), Array[scala.xm\
l.Node]{})
        }
      };
      if (temp0.isInstanceOf[scala.xml.Elem]())
        {
          var temp1: scala.xml.Elem = temp0.asInstanceOf$erased[scala.xml.Elem]();
          temp1.prefix().isInstanceOf[scala.Seq[scala.xml.Node]]().&&(temp1.prefix().asInstanceOf$erased\
[scala.Seq[scala.xml.Node]]().length().==(1)).&&({
            var temp2: scala.Seq[scala.xml.Node] = temp1.prefix().asInstanceOf$erased[scala.Seq[scala.xml.Node]]\
();
            if (temp2.apply(0).isInstanceOf[scala.xml.Elem]())
              {
                var temp3: scala.xml.Elem = temp2.apply(0).asInstanceOf$erased[scala.xml.Elem]();
                if (temp3.label().==("hello"))
                  temp3.child().isInstanceOf[scala.Seq[scala.xml.Node]]().&&(temp3.child().asInstanceOf$\
erased[scala.Seq[scala.xml.Node]]().length().==(0)).&&({
                    var temp4: scala.Seq[scala.xml.Node] = temp3.child().asInstanceOf$erased[scala.Seq[scala.xml\
.Node]]();
                    {
                      {
                        <synthetic> val r$0: scala.Boolean = true;
                        exit(r$0);
                        true
                      }
                    }
                  })
                else
                  false
              }
            else
              false
          })
        }
      else
        false.||({
        {
          <synthetic> val r$1: scala.Boolean = false;
          exit(r$1);
          true
        }
      });
      throw new scala.MatchError.<init>(temp0);
      exit(result){
        result
      }
    }
  }
}
what expected That it behaves equivalent to the following code, which works
object Test extends Application {

  <hello/> match { case scala.xml.Elem(_,"hello",_,_) => true; case _ => false; };

}
the result of translating pattern matching is:
package <empty> {
  final class Test extends java.lang.Object with scala.Application with scala.ScalaObject {
    def <init>(): Test = {
      Test.super.<init>();
      ()
    };
    {
      var temp0: scala.xml.Elem = {
        {
          new scala.xml.Elem.<init>(null, "hello", scala.xml.Null, scala.this.Predef.$scope(), Array[scala.xml.Node]{})
        }
      };
      if (temp0.isInstanceOf[scala.xml.Elem]())
        {
          var temp1: scala.xml.Elem = temp0.asInstanceOf$erased[scala.xml.Elem]();
          if (temp1.label().==("hello"))
            temp1.child().isInstanceOf[scala.Seq[scala.xml.Node]]().&&(temp1.child().asInstanceOf$erased[scala.Seq[scala.xml.Node]]().length().==(0)).&&({
              var temp2: scala.Seq[scala.xml.Node] = temp1.child().asInstanceOf$erased[scala.Seq[scala.xml.Node]]();
              {
                {
                  <synthetic> val r$0: scala.Boolean = true;
                  exit(r$0);
                  true
                }
              }
            })
          else
            false
        }
      else
        false.||({
        {
          <synthetic> val r$1: scala.Boolean = false;
          exit(r$1);
          true
        }
      });
      throw new scala.MatchError.<init>(temp0);
      exit(result){
        result
      }
    }
  }
}
[back to overview]
Changes of this bug report