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

Defining any method named conforms breaks Scala collections #7788

Closed
scabug opened this issue Aug 27, 2013 · 6 comments
Closed

Defining any method named conforms breaks Scala collections #7788

scabug opened this issue Aug 27, 2013 · 6 comments

Comments

@scabug
Copy link

scabug commented Aug 27, 2013

This is a fun one:

scala> class C {
     |   def conforms(x: Int, y: Int) = x < y
     |   val xs = List((1, 2), (3, 4))
     |   println(xs.unzip)
     | }
<console>:11: error: No implicit view available from (Int, Int) => (A1, A2).
         println(xs.unzip)              ^

The problem is that Predef.conforms is shadowed by the local conforms. It took me a while to figure out what happened.

IMO this is a trap waiting to happen for everyone. We should avoid it by finding a less conspicuous name for the conversion. Ideally with a dollar in it.

@scabug
Copy link
Author

scabug commented Aug 27, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7788?orig=1
Reporter: @odersky
Affected Versions: 2.10.3

@scabug
Copy link
Author

scabug commented Dec 3, 2013

@retronym said:
Special treatment of this method name is hard-coded in the IntelliJ presentation compiler's implicit search; we'll have to notify them if/when we change.

@scabug
Copy link
Author

scabug commented Dec 3, 2013

@retronym said:
I'm thinking that I might add a(nother) special case for conforms to disable shadowing checks.

In doing so, I found some problems with the roundabout way that implicit search detects and reports shadowing, so I'll fix that too.

WIP: https://github.com/retronym/scala/compare/topic;7788?expand=1

@scabug
Copy link
Author

scabug commented Dec 3, 2013

@retronym said:
scala/scala#3217

@scabug
Copy link
Author

scabug commented Jan 17, 2014

@adriaanm said:
how about deprecating Predef.conforms, removing its implicit status, and adding a implicit def __$MAGIC$__conforms to Predef?

@scabug
Copy link
Author

scabug commented Feb 18, 2014

@adriaanm said:
scala/scala#3555

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

2 participants