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

Implicit shadowing fail #11421

som-snytt opened this Issue Mar 1, 2019 · 1 comment


None yet
1 participant
Copy link

som-snytt commented Mar 1, 2019

In normal lexical scope, the "package-level" import shadows the def in the package object, so g compiles. Implicit resolution ought to see the same thing, but f fails to find an implicit value.

One file:

package post.fix

object `package` {
  implicit def postfixOps = scala.language.postfixOps

Another file:

package post.fix

import scala.language.postfixOps
trait T {
  //import scala.language.postfixOps      // compiles here
  //def f[A](xs: List[A]): Int = xs length    // sample feature lookup has same behavior
  def g = postfixOps       // resolves correctly
  def f = implicitly[languageFeature.postfixOps]  // fails to compile


postfixuser.scala:10: postfixOps is not a valid implicit value for languageFeature.postfixOps because:
candidate implicit method postfixOps in package fix is shadowed by lazy value postfixOps in object language
  def f = implicitly[languageFeature.postfixOps]
postfixuser.scala:10: error: could not find implicit value for parameter e: languageFeature.postfixOps
  def f = implicitly[languageFeature.postfixOps]

As noticed by a Scala contributor.


This comment has been minimized.

Copy link

som-snytt commented Mar 1, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.