title: How to resolve ambiguous implicit conversion method that takes same input type in Scala?
body: <p>I have read other same <a href="https://stackoverflow.com/questions/6948135/resolving-ambiguous-implicit-conversions-in-scala">question</a> here, however the case is too specific for certain built-in class. I want to ask for simple case here and hoping for general answer.</p>
  
  <p>So I have this code:</p>
  
  <pre><code>object ScalaApp {    
      case class Point(x: Int, y: Int);
  
      case class Rational(n: Int, d: Int) {
          def \(i: Int): List[Int] = n :: d:: i :: Nil
      }
  
      case class MyObject(x: Int, y: Int, z: Int) {
          def \(i: Int): List[Int] = x :: y:: i :: Nil
      }
  
      implicit def pointToRational(p: Point): Rational = Rational(p.x + 1, p.y * 2)
  
      implicit def pointToMyObject(p: Point): MyObject = MyObject(p.x, p.y, p.x+p.y)
  
      def main(args: Array[String]) {
          val p = Point(5, 7)
          val result = p \ 6    // compile error here
      }
  }
  </code></pre>
  
  <p>We can see the error happened when <code>p</code> is applied to <code>\</code> method then the implicit conversion is triggered. Scala compiler will try to look for any imported or local class that has <code>def \(i: Int)</code> method defined. If found, then it will try to look for any implicit conversion method that take <code>Point</code> type and return the type of object that has <code>def \(i: Int)</code> method signature.</p>
  
  <p>It happened there are two class that has <code>def \</code> method here: <code>Rational</code> and <code>MyObject</code>, and there are two implicit methods too: <code>pointToRational</code> and <code>pointToMyObject</code> for those two classes.</p>
  
  <p>However since both <code>Rational</code> and <code>MyObject</code> has <code>def \</code> defined, hence the ambiguous compile error occured because it can't decide which one should be taken.</p>
  
  <pre><code>Error:(30, 22) type mismatch;
   found   : p.type (with underlying type ScalaApp.Point)
   required: ?{def \(x$1: ? &gt;: Int(6)): ?}
  Note that implicit conversions are not applicable because they are ambiguous:
   both method pointToRational in object ScalaApp of type (p: ScalaApp.Point)ScalaApp.Rational
   and method pointToObj in object ScalaApp of type (p: ScalaApp.Point)ScalaApp.MyObject
   are possible conversion functions from p.type to ?{def \(x$1: ? &gt;: Int(6)): ?}
          val result = p \ 6
                       ^
  </code></pre>
  
  <p>So my question, is there a way to resolve the ambiguous implicit error but still retaining the two <code>def \</code> methods or without removing one of implicit conversion method?</p>