Skip to content

Defining any method named conforms breaks Scala collections #7788

@scabug

Description

@scabug

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions