Fixed equality to be symmetric with respect to Atom.

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@14555 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
washburn 2008-04-08 15:42:54 +00:00
parent a7487d0098
commit ebe87cf0d7
2 changed files with 4 additions and 2 deletions

View File

@ -25,8 +25,9 @@ case class Text(_data: String) extends Atom[String](_data) {
throw new java.lang.NullPointerException("tried to construct Text with null")
final override def equals(x: Any) = x match {
case s:String => s.equals(data)
case s:String => s == data
case s:Text => data == s.data
case s:Atom[_] => data == s.data
case _ => false
}

View File

@ -23,9 +23,10 @@ case class Unparsed(_data: String) extends Atom[String](_data) {
throw new java.lang.NullPointerException("tried to construct Unparsed with null")
final override def equals(x: Any) = x match {
case s:String => s.equals(data)
case s:String => s == data
case s:Text => data == s.data
case s:Unparsed => data == s.data
case s:Atom[_] => data == s.data
case _ => false
}