Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SeqView violated rules for java.lang.Object.equals #10201

Closed
scabug opened this issue Feb 21, 2017 · 5 comments
Closed

SeqView violated rules for java.lang.Object.equals #10201

scabug opened this issue Feb 21, 2017 · 5 comments

Comments

@scabug
Copy link

scabug commented Feb 21, 2017

In JavaDoc for Object.equals

It is reflexive: for any non-null reference value x, x.equals\(x\) should return true.

However, SeqView does not conform the rule:

Welcome to Scala 2.12.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_102).
Type in expressions for evaluation. Or try :help.

scala> val v = Seq(0.0, 1.0).view.map{ d => d + math.random }
v: scala.collection.SeqView[Double,Seq[_]] = SeqViewM(...)

scala> v == v
res0: Boolean = false
@scabug
Copy link
Author

scabug commented Feb 21, 2017

Imported From: https://issues.scala-lang.org/browse/SI-10201?orig=1
Reporter: @Atry
Affected Versions: 2.12.1

@scabug
Copy link
Author

scabug commented Feb 21, 2017

@Atry said (edited on Feb 21, 2017 9:51:54 AM UTC):
I think the only way to make SeqView conform these rules is making SeqView not be a GenSeq or Seq any more, though SeqView can extends GenSeqLike and SeqLike.

@scabug
Copy link
Author

scabug commented Mar 1, 2017

@Atry said:
Looks like the issue will be fixed in 2.13:
http://www.scala-lang.org/blog/2017/02/28/collections-rework.html

@scabug
Copy link
Author

scabug commented Mar 9, 2017

@szeiger said:
Related discussion for 3.13: scala/collection-strawman#13 (comment)

@scabug scabug added this to the 2.13.0-RC1 milestone Apr 7, 2017
@szeiger szeiger modified the milestones: 2.13.0-RC1, 2.13.0-M4 Apr 23, 2018
@szeiger
Copy link
Member

szeiger commented Apr 23, 2018

Fixed in 2.13.x for 2.13.0-M4. Views are compared by identity in the new collection library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants