Cannot decompile the companion object of an opaque type in Scala 3
Describe the bug
Reproduction steps:
- Check out https://github.com/Atry/metals-decompile
- Open the project in VS Code with Metals
- Import the project with bloop compiler server
- Open
src/main/scala/mypackage/MyOpaqueType.scalain the editor - From the Command Palette, run "Metals: Show decompiled with javap verbose"
Then the error message is shown in a new tab
File file:///private/tmp/metals-decompile/.bloop/metals-decompile/bloop-bsp-clients-classes/classes-Metals-TMvkzg3KQmK96kYMLWlZKQ==/mypackage/MyOpaqueType$.class doesn't exist
Expected behavior
Show decompiled in a new tab
Operating system
macOS
Editor/Extension
VS Code
Version of Metals
0.11.2
Extra context or search terms
Note that there is a class file compiled from the companion object at mypackage/MyOpaqueType$package$MyOpaqueType$.class, not mypackage/MyOpaqueType$.class.
Thanks for reporting! It looks like with opaque type the object classfile is different than when the object is a companion to a non opaque topelevel type.
mypackage/MyOpaqueType$package$MyOpaqueType$.class instead of mypackage/MyOpaqueType$.class
If we put the type into another class/object then the resulting classfiles are as we would expect them. We could special case this scenario or see if it actually needs to be fixed in the compiler