3
    trait TriIndexable[M[_,_,_,_]] {
      def get[A,B,C,D](m: M[A,B,C,D])(a: A, b: B, c: C): Unit
    }
    implicit object TriMapTriIndexable extends TriIndexable[TriMap] {
      def get[A,B,C,D](m: TriMap[A,B,C,D])(a: A, b: B, c: C): Unit = {
        println("Tri indexable get")
      }
    }
    type TriIntMap[D] = TriMap[Int,Int,Int,D]
    trait TupleIntIndexable[M[_]] {
      def get[D](m: M[D])(a: (Int, Int, Int)): Unit
    }
    implicit object TriIntMapTupleIntIndexable extends TupleIntIndexable[TriIntMap] {
        def get[D](m: TriIntMap[D])(a: (Int, Int, Int)): Unit = {
        println("Tri Int indexable get")
      }
    }
    class TriMap[A,B,C,D]() {
    }
    implicit class TriIndexableOps[A,B,C,D,M[_,_,_,_]](
          val tri: M[A,B,C,D]
    )(implicit ev: TriIndexable[M]) {
        def get(a: A, b: B, c: C) = {
        ev.get(tri)(a,b,c)
    }
    }
    implicit class TupleIntIndexableOps[D,M[_]](
          val tri: M[D]
    )(implicit ev: TupleIntIndexable[M]) {
        def get(a: (Int,Int,Int)) = {
        ev.get(tri)(a)
    }
    }
    val test: TriIntMap[String] = new TriMap[Int,Int,Int,String]()
    test.get(5,5,5)
    test.get((5,5,5))

not enough arguments for method get: (a: Int, b: Int, c: Int): Unit. Unspecified value parameters b, c.

Why does this error on the last line? I'm trying to give a subset of TriMaps the ability to index with another object, in this case it's a tuple of three ints. How can I fix this?

https://scastie.scala-lang.org/pMEa7Zq6TLeBxq1k9zG1oA

Gaël J
  • 11,274
  • 4
  • 17
  • 32
Thomas
  • 6,032
  • 6
  • 41
  • 79
  • You could e.g. rename one of `get` methods or put tupled and regular method into the same implicit class. – michaJlS May 31 '21 at 09:21
  • Also https://stackoverflow.com/questions/64016090/2-extension-methods-with-the-same-name-in-different-classes-do-not-work-in-scala – michaJlS May 31 '21 at 09:23

0 Answers0