Skip to content

Unability to use objects with name eq when compiled with Scala 2 #6242

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

Closed
buzden opened this issue Apr 5, 2019 · 3 comments
Closed

Unability to use objects with name eq when compiled with Scala 2 #6242

buzden opened this issue Apr 5, 2019 · 3 comments

Comments

@buzden
Copy link
Contributor

buzden commented Apr 5, 2019

Dotty thinks that every package compiled by Scala 2 has the eq method in it. This gives two consequences.


First, strange code compiles. Considering as an example, you have cats library in dependencies, you have

val z = cats.eq(new Object) // Compiles!

Second, all objects that have name eq in such packages, become unavailable. Considering, for example, you have cats-laws library in dependencies, this code

import cats.laws.discipline.eq._

fails with

[error] -- Error: dotty-eq-bug/src/main/scala/dottyeq/tst-pos.scala:4:28 
[error] 4 |import cats.laws.discipline.eq._
[error]   |       ^^^^^^^^^^^^^^^^^^^^^^^
[error]   |       Object => Boolean is not stable

This error appears both in pure dotty mode and in dotty's scala 2 compatibility mode.


The minimal project showing both errors can be found here.

@smarter
Copy link
Member

smarter commented Apr 5, 2019

Both cats and cats.laws.discipline contain a package object, and objects always have an eq method, so Dotty's behavior isn't completely unreasonable here but we should still align with Scala 2. @adriaanm do you happen to know if scalac has some logic somewhere to skip members of Any when looking into package objects ?

@adriaanm
Copy link
Contributor

adriaanm commented Apr 5, 2019

Don't know, sorry. I poked around a bit, but didn't see anything obvious...

odersky added a commit that referenced this issue May 12, 2019
Fix #6242: package objects leak members from Any and Object
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