From bf1bb310a389dacc509cee8969fd660214703544 Mon Sep 17 00:00:00 2001 From: Katarzyna Marek Date: Tue, 5 Dec 2023 13:44:29 +0100 Subject: [PATCH] bugfix: don't show implicit conversions for synthetics --- .../pc/PcSyntheticDecorationsProvider.scala | 3 +- .../SyntheticDecorationsLspSuite.scala | 42 +++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/mtags/src/main/scala-2/scala/meta/internal/pc/PcSyntheticDecorationsProvider.scala b/mtags/src/main/scala-2/scala/meta/internal/pc/PcSyntheticDecorationsProvider.scala index 37d047b3482..5e9adb54d41 100644 --- a/mtags/src/main/scala-2/scala/meta/internal/pc/PcSyntheticDecorationsProvider.scala +++ b/mtags/src/main/scala-2/scala/meta/internal/pc/PcSyntheticDecorationsProvider.scala @@ -95,7 +95,8 @@ final class PcSyntheticDecorationsProvider( object ImplicitConversion { def unapply(tree: Tree): Option[(String, Position)] = tree match { - case Apply(fun, args) if isImplicitConversion(fun) => + case Apply(fun, args) + if isImplicitConversion(fun) && args.exists(_.pos.isRange) => val lastArgPos = args.lastOption.fold(fun.pos)(_.pos) Some((fun.symbol.decodedName, lastArgPos)) case _ => None diff --git a/tests/unit/src/test/scala/tests/decorations/SyntheticDecorationsLspSuite.scala b/tests/unit/src/test/scala/tests/decorations/SyntheticDecorationsLspSuite.scala index 0b02156f514..bfaf507b3ee 100644 --- a/tests/unit/src/test/scala/tests/decorations/SyntheticDecorationsLspSuite.scala +++ b/tests/unit/src/test/scala/tests/decorations/SyntheticDecorationsLspSuite.scala @@ -951,4 +951,46 @@ class SyntheticDecorationsLspSuite extends BaseLspSuite("implicits") { ) } yield () } + + test("i4970") { + for { + _ <- initialize( + """|/metals.json + |{ + | "a": { + | "libraryDependencies": [ + | "co.fs2::fs2-core:3.9.0" + | ] + | } + |} + |/a/src/main/scala/Main.scala + |import cats.effect.IO + | + |object Test { + | def foo(str: fs2.Stream[IO, Int]) = + | str.compile.to(Set) + |} + |""".stripMargin + ) + _ <- server.didChangeConfiguration( + """{ + | "show-implicit-conversions-and-classes": true + |} + |""".stripMargin + ) + _ <- server.didOpen("a/src/main/scala/Main.scala") + _ <- server.didSave("a/src/main/scala/Main.scala")(identity) + _ = assertNoDiagnostics() + _ = assertNoDiff( + client.syntheticDecorations, + """|import cats.effect.IO + | + |object Test { + | def foo(str: fs2.Stream[IO, Int]) = + | str.compile.to(supportsIterableFactory(Set)) + |} + |""".stripMargin, + ) + } yield () + } }