Skip to content

Abstract type members lost their implicit scope #8396

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
neko-kai opened this issue Feb 27, 2020 · 0 comments
Closed

Abstract type members lost their implicit scope #8396

neko-kai opened this issue Feb 27, 2020 · 0 comments

Comments

@neko-kai
Copy link
Contributor

minimized code

trait Show[A] { def show(a: A): String = a.toString }

object Prefix {
  type AbstractType
  type UpperBoundedType <: String
  type FullyBoundedType >: String <: String
  
  given A as Show[AbstractType]
  given B as Show[UpperBoundedType]
  given C as Show[FullyBoundedType]
}

object App extends App {
  println(s"implicit: ${implicitly[Show[Prefix.AbstractType]]}")
  println(s"implicit: ${implicitly[Show[Prefix.UpperBoundedType]]}")
  println(s"implicit: ${implicitly[Show[Prefix.FullyBoundedType]]}")
}

Scastie: https://scastie.scala-lang.org/otro4pYkQHiwGX9VPfUxaA

Compilation output

no implicit argument of type Show[Prefix.AbstractType] was found for parameter ev of method implicitly in object DottyPredef
no implicit argument of type Show[Prefix.UpperBoundedType] was found for parameter ev of method implicitly in object DottyPredef
no implicit argument of type Show[Prefix.FullyBoundedType] was found for parameter ev of method implicitly in object DottyPredef

expectation

Expected it to compile and work correctly, same as in Scala 2!
Scala 2 Scastie: https://scastie.scala-lang.org/I0odfeihTk2MdATPBDKlOg)
Output:

implicit: Prefix$A$@22b7f158
implicit: Prefix$B$@27bab57c
implicit: Prefix$C$@13df130b
nicolasstucki added a commit that referenced this issue Mar 4, 2020
Fix #8396: Make prefixes of abstract types contribute to implicit scope
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

1 participant