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

bugfix: Make mtags-shared published with full scala version #5380

Merged
merged 2 commits into from
Jun 28, 2023
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
6 changes: 4 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ lazy val mtagsShared = project
crossScalaVersions := {
V.supportedScalaVersions ++ V.nightlyScala3Versions
},
crossVersion := CrossVersion.binary,
crossVersion := CrossVersion.full,
Compile / packageSrc / publishArtifact := true,
libraryDependencies ++= List(
"org.lz4" % "lz4-java" % "1.8.0",
Expand Down Expand Up @@ -355,6 +355,8 @@ lazy val mtags3 = project
sharedSettings,
mtagsSettings,
Compile / unmanagedSourceDirectories += (ThisBuild / baseDirectory).value / "mtags" / "src" / "main" / "scala",
Compile / unmanagedSourceDirectories += (ThisBuild / baseDirectory).value / "mtags-shared" / "src" / "main" / "scala",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to change this, since we had issues compiling mtagsShared with full version and using it from mtags3. This is just a workaround to support Scala 3 better inside Metals, so this is totally fine.

Compile / unmanagedSourceDirectories += (ThisBuild / baseDirectory).value / "mtags-shared" / "src" / "main" / "scala-3",
moduleName := "mtags3",
scalaVersion := V.scala3,
target := (ThisBuild / baseDirectory).value / "mtags" / "target" / "target3",
Expand All @@ -363,7 +365,7 @@ lazy val mtags3 = project
(ThisBuild / baseDirectory).value / ".scalafix3.conf"
),
)
.dependsOn(mtagsShared)
.dependsOn(interfaces)
.enablePlugins(BuildInfoPlugin)

lazy val mtags = project
Expand Down
16 changes: 11 additions & 5 deletions metals/src/main/scala/scala/meta/internal/metals/Embedded.scala
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,7 @@ final class Embedded(
case None => resolutionParams
case Some(version) =>
resolutionParams.forceVersions(
List(
Dependency.of("org.scala-lang", "scala3-library_3", version),
Dependency.of("org.scala-lang", "scala3-compiler_3", version),
Dependency.of("org.scala-lang", "tasty-core_3", version),
).map(d => (d.getModule, d.getVersion)).toMap.asJava
Embedded.scala3CompilerDependencies(version)
)
}
val jars =
Expand Down Expand Up @@ -180,6 +176,12 @@ object Embedded {
),
)

private[Embedded] def scala3CompilerDependencies(version: String) = List(
Dependency.of("org.scala-lang", "scala3-library_3", version),
Dependency.of("org.scala-lang", "scala3-compiler_3", version),
Dependency.of("org.scala-lang", "tasty-core_3", version),
).map(d => (d.getModule, d.getVersion)).toMap.asJava

def fetchSettings(
dep: Dependency,
scalaVersion: Option[String],
Expand All @@ -197,6 +199,10 @@ object Embedded {
Dependency.of("org.scala-lang", "scala-reflect", scalaVersion),
).map(d => (d.getModule, d.getVersion)).toMap.asJava
)
else
resolutionParams.forceVersions(
scala3CompilerDependencies(scalaVersion)
)
}

Fetch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,54 @@ class CompletionCrossLspSuite
} yield ()
}

test("iskra-scala3") {
cleanWorkspace()
for {
_ <- initialize(
s"""/metals.json
|{
| "a": {
| "scalaVersion": "${V.scala3}",
| "libraryDependencies": [
| "org.virtuslab::iskra:0.0.3"
| ]
| }
|}
|/a/src/main/scala/Main.scala
|
|import org.virtuslab.iskra.api.*
|import org.virtuslab.iskra.api.given
|
|given spark: SparkSession = SparkSession
| .builder()
| .master("local")
| .appName("my-spark-app")
| .getOrCreate()
|
|object demo {
|
| case class Foo(x: Int, y: Int)
|
| val df = Seq(Foo(1, 420), Foo(2, 50)).toTypedDF
| // @@
| df.select {
| val sum = ($$.x + $$.y).as("sum")
| ($$.x, $$.y, sum)
| }
|
|}
|
|""".stripMargin
)
_ <- server.didOpen("a/src/main/scala/Main.scala")
_ = assertNoDiagnostics()
_ <- assertCompletion(
"df.sel@@",
"""|select: Select[?]
|""".stripMargin,
filename = Some("a/src/main/scala/Main.scala"),
)
} yield ()
}

}
Loading