“Insert type annotation” wrongly infers `Any` type
Describe the bug
- Clone this repo: https://github.com/zio/zio-http/
- check out commit ade9245c (current
mainas of this writing) - open the project using VS Code, import project (bloop or sbt, doesn't matter)
- Remove the type annotation from
val liveinobject NettyClientDriver, save file - use the insert type annotation feature to add the type annotation again
Metals will infer Any instead of the correct type
Expected behavior
The inferred type should be ZLayer[NettyConfig, Nothing, NettyClientDriver]
Operating system
Linux
Editor/Extension
VS Code
Version of Metals
v1.3.1
Extra context or search terms
No response
Another issue is:
In the same file, go to line 89. Position the cursor on line 89 between the leading dot and the word customHeaders. Trigger code completion -> works fine, you get all the right methods.
Move the cursor to line 90 between the leading dot and the word webSocketUri. Trigger code completion -> You only get junk.
Looking into the project it seems that for both Bloop and sbt BSP it's failing. The weirdest thing is that the presentation compiler seems to be sending us errors all around :thinking:
It looks mostly fine in the Metals doctor though 🤷🏻♂️
Perhaps it is somehow related to the sbt-projectmatrix plugin?
Not sure, either presentation compiler is doing something weird or we are giving it a wrong classpath somehow.
Finally, going back to the issue I see a lot of:
[error] zio.http.netty.client.NettyClientDriver.requestWebsocket(file:///home/tgodzik/Documents/metals/tests/unit/target/e2e/community/zio/zio-http/jvm/src/main/scala/zio/http/netty/client/NettyClientDriver.scala:129)
[error]
[error] No automatically generated traces are permitted here. Add an implicit parameter
[error] to pass through a user generated trace or explicitly call `newTrace`
[error] to force generation of a new trace.
[error]
[error] copy/paste:
[error] (implicit trace: Trace) <- no existing implicit parameter list
[error] , trace: Trace <- existing implicit parameter list
[error] (newTrace) <- I know what I'm doing, generate a new trace anyway
[error]
and anything that takes in trace as a parameter fails.
Yep, looks like if I remove import zio.stacktracer.TracingImplicits.disableAutoTrace everything works :O
Looks like it also works with implicit val trace: Tracer.instance.Type with Tracer.Traced = Trace.empty it doesn't like the alias
Turns out this is a duplicate of https://github.com/scalameta/metals/issues/4495 which is caused itself by https://github.com/scala/bug/issues/12663
If you are in any other package than zio this will be fine.