title: Implicit conversion with implicit parameter
body: <p>I'm implementing a Java interface with a lot of methods with Object parameters, which in my case are really Strings containing user names:</p>
  
  <pre><code>public interface TwoFactorAuthProvider {
      boolean requiresTwoFactorAuth(Object principal);
      ... //many more methods with the same kind of parameter
  }
  </code></pre>
  
  <p>I'm trying to use implicit conversion to convert these to <code>User</code> objects in my implementation:</p>
  
  <pre><code>class TwoFactorAuthProviderImpl(userRepository: UserRepository) 
      extends TwoFactorAuthProvider {
  
      def requiresTwoFactorAuth(user: User): Boolean = {
          ...
      }
  }
  </code></pre>
  
  <p>When I define the conversion in the companion object of my class, it is picked up just fine and my class compiles:</p>
  
  <pre><code>object TwoFactorAuthProviderImpl {
      implicit def toUser(principal: Any): User = {
          null //TODO: do something useful
      }
  }
  </code></pre>
  
  <p>However, to be able to do the conversion, I need access to the user repository, which the <code>TwoFactorAuthProviderImpl</code> instance has, but the companion object does not. I thought I could possibly use an implicit parameter to pass it:</p>
  
  <pre><code>implicit def toUser(principal: Any)(implicit repo: UserRepository): User = {
      val email = principal.asInstanceOf[String]
      repo.findByEmail(email)
  }
  </code></pre>
  
  <p>But with the implicit parameter, the conversion is no longer picked up by the compiler (complaining that I'm not implementing the interface).</p>
  
  <p>Is there a way to get the implicit conversion that I want, or is this outside the scope of what you can do with implicits?</p>