-
Notifications
You must be signed in to change notification settings - Fork 326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type information errors when classloading in macros with Selectable
#6494
Comments
Thanks for the report. It seems that loading java.lang.ClassNotFoundException: java.sql.Driver
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:593)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:421)
at java.base/java.lang.Class.forName(Class.java:412)
at a.LoadStuff$.makeImpl(LoadStuff.scala:13)
at a.LoadStuff$.inline$makeImpl(LoadStuff.scala:10) |
Thanks for the quick response. How did you get that stack trace? I didn't see it in the logs that I referenced. Is the classpath for the interactive driver configurable? |
I got it from diagnostics inside of presentation compiler. It isn't surfaced anywhere.
In Metals we take the classpath for the specific build target according to what the build server (so the build tool really) says. But this error only occurs if |
Thanks for the info. If it's the same classpath, I wonder how it diverges from the build tool. Additionally, I can say that this also works correctly when building from sbt (but still broken in Metals). Actually, thinking about it, this has nothing to do with object LoadStuff:
transparent inline def make: Unit = ${ makeImpl }
private def makeImpl(using Quotes): Expr[Unit] =
Class.forName("org.h2.Driver")
'{()} This too triggers a loss of type-information at the call-site of Removing |
Describe the bug
Hello,
I'm trying to connect to a database via JDBC in a macro, for, um, educational purposes. I then want to use
Selectable
to reflect the data from the database in a structural type (in the style of type providers).Despite everything compiling fine, it seems that Metals is having issues when I actually try to touch the database.
Here's a minimized reproduction.
Notice that I'm accessing a class from the H2 driver while running the macro. The result of the macro is a refined type.
I can then use it in a separate file as follows:
This compiles and runs correctly. But Metals loses all type information. I can't get member completions on the
load
value. And I cannot automatically insert a type annotations, it fails with an error.Following the logs, I see that I get the following error when trying to insert a type annotation:
And opening one of the error files, I see this:
If I remove the
Class.forName
call everything works as expected, with member completion and generated type annotations.Please let me know if I can provide any further info.
Thanks
Expected behavior
Selectable
types should work correctly, with type member selection hints regardless of the access to library classes.Operating system
None
Editor/Extension
VS Code
Version of Metals
v1.35.5
Extra context or search terms
No response
The text was updated successfully, but these errors were encountered: