scalameta / metals

Scala language server with rich IDE features 🚀
https://scalameta.org/metals/
Apache License 2.0
2.04k stars 318 forks source link

Incorrect overload chosen in navigation to extension method #6558

Open reynaldjoabet opened 1 week ago

reynaldjoabet commented 1 week ago

Describe the bug

import org.typelevel.twiddles.syntax.*
List(7)*:List(2)

When you click on *:, you get the wrong extension method(cons)

   extension [F[_], A](fa: F[A])
    @annotation.targetName("cons")
    def *:[G[x] >: F[x], B <: Tuple](gb: G[B])(using InvariantSemigroupal[G]): G[A *: B] =
      fa.product(gb).imap[A *: B] { case (hd, tl) => hd *: tl } { case hd *: tl => (hd, tl) }

    @annotation.targetName("pair")
    @annotation.nowarn
    def *:[G[x] >: F[x], B](gb: G[B])(using InvariantSemigroupal[G]): G[A *: B *: EmptyTuple] =
      fa.product(gb).imap[A *: B *: EmptyTuple] { case (a, b) => a *: b *: EmptyTuple } {
        case a *: b *: EmptyTuple => (a, b)
      }

Expected behavior

  @annotation.targetName("pair")
    @annotation.nowarn
    def *:[G[x] >: F[x], B](gb: G[B])(using InvariantSemigroupal[G]): G[A *: B *: EmptyTuple] =
      fa.product(gb).imap[A *: B *: EmptyTuple] { case (a, b) => a *: b *: EmptyTuple } {
        case a *: b *: EmptyTuple => (a, b)
      }

Operating system

macOS

Editor/Extension

VS Code

Version of Metals

v1.3.2

Extra context or search terms

No response

tgodzik commented 6 days ago

Thanks for reporting! Looks like we don't handle things with targetName correctly :thinking: