Skip to content

Commit

Permalink
bugfix: don't show implicit conversions for synthetics
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek authored and tgodzik committed Dec 5, 2023
1 parent f1ed4af commit bf1bb31
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
}
}

0 comments on commit bf1bb31

Please sign in to comment.