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
Duplicate implicits in package object #3999
Comments
Imported From: https://issues.scala-lang.org/browse/SI-3999?orig=1 |
@paulp said: Note that implicit conversions are not applicable because they are ambiguous:
both method boolean2ValSI-9273 in package barSI-9264 of type (bSI-11195: BooleanSI-3807)foo.bar.packageSI-9265.ValSI-9272
and method boolean2ValSI-9273 in package barSI-9264 of type (bSI-11195: BooleanSI-3807)foo.bar.package.ValSI-9272
are possible conversion functions from BooleanSI-3807(false) to fooSI-9261.barSI-9263.packageSI-9265.ValSI-9272 So I guess foo.bar.packageSI-9265.ValSI-9272 != foo.bar.package.ValSI-9272. Is that the package object vs. the package object class? |
@lrytz said: |
s wade (swadenator) said: // test.scala
object `package` {
trait Score { def toString : String }
trait Test[+T <: Score] { def apply(s : String) : T }
case class FT(f : Float) extends Score
implicit object FT extends Test[FT] { def apply(s : String) : FT = new FT(s.toFloat) }
case class IT(i : Int) extends Score
implicit object IT extends Test[IT] { def apply(s : String) : IT = new IT(s.toInt) }
}
class TT[+T <: Score](implicit val tb : Test[T]) {
def read(s : String) : T = tb(s)
}
object Tester {
val tt = new TT[FT]
val r = tt.read("1.0")
r.toString
} // test2.scala
object Tester {
trait Score { def toString : String }
trait Test[+T <: Score] { def apply(s : String) : T }
case class FT(f : Float) extends Score
implicit object FT extends Test[FT] { def apply(s : String) : FT = new FT(s.toFloat) }
case class IT(i : Int) extends Score
implicit object IT extends Test[IT] { def apply(s : String) : IT = new IT(s.toInt) }
class TT[+T <: Score](implicit val tb : Test[T]) {
def read(s : String) : T = tb(s)
}
val tt = new TT[FT]
val r = tt.read("1.0")
r.toString
}
|
@paulp said: |
In foo/bar/package.scala:
In foo/bar/A.scala:
The text was updated successfully, but these errors were encountered: