Skip to content
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

Presentation Compiler is now loaded with correct classloader #7002

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package scala.meta.internal.metals
* method signatures of the `PresentationCompiler` class.
*/
class PresentationCompilerClassLoader(parent: ClassLoader)
extends ClassLoader(null) {
extends ClassLoader(ClassLoader.getSystemClassLoader().getParent()) {
override def findClass(name: String): Class[_] = {
val isShared =
name.startsWith("org.eclipse.lsp4j") ||
Expand Down
56 changes: 56 additions & 0 deletions tests/unit/src/test/scala/tests/ClassloaderModulesSupport.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package tests

import scala.meta.internal.metals.BuildInfo

class ClassloaderModulesSupport
extends BaseLspSuite("classloader-modules-")
with TestHovers {

test("basic") {
cleanWorkspace()
for {
_ <- initialize(
s"""/metals.json
|{
| "a": { "scalaVersion": "${BuildInfo.scala3}" },
| "b": { "dependsOn": ["a"], "scalaVersion": "${BuildInfo.scala3}" }
|}
|
|/a/src/main/scala/a/A.scala
|package a
|
|import scala.quoted._
|
|object MacroImpl:
| transparent inline def make = $${ makeImpl }
|
| private def makeImpl(using Quotes): Expr[Unit] =
| Class.forName("java.sql.Driver")
| '{()}
|
|/b/src/main/scala/b/B.scala
|package b
|
|object B:
| a.MacroImpl.make
|""".stripMargin
)
_ <- server.didOpen("a/src/main/scala/a/A.scala")
_ <- server.didOpen("b/src/main/scala/b/B.scala")
_ = assertNoDiagnostics()
_ <- server.assertHover(
"b/src/main/scala/b/B.scala",
"""
|/b/src/main/scala/b/B.scala
|package b
|
|object B:
| a.MacroImpl.ma@@ke
|""".stripMargin,
"""|
|inline transparent def make: Unit
|""".stripMargin.hover,
)
} yield ()
}
}
Loading