scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
230 stars 21 forks source link

private implicit conversion from Array in the companion object not visible in its class #12793

Open noresttherein opened 1 year ago

noresttherein commented 1 year ago

Reproduction steps

Scala version: 2.13.10

import Boo.Hamster

class Boo[A] {
    private[this] def array :Array[A] = ???
    array.roar_!!!
}

object Boo {
    private class Hamster[A] {
        def roar_!!! = ???
    }
    private implicit def Hamster[A](array :Array[A]) :Hamster[A] = new Hamster
}

Problem

value roar_!!! is not a member of Array[A]
    array.roar_!!!

Works if the conversion and class are made public. Works also for user types in place of Array[A].

Jasper-M commented 1 year ago

Works also for user types in place of Array[A].

I don't see that.

som-snytt commented 1 year ago

Me neither. I started looking yesterday. Very confusing failure.

I think I noticed that it works when the import is inside the class, so it's a bad access check when the context of the implicit is an import context at a source location where you couldn't write the implicit application explicitly.