diff --git a/build.sbt b/build.sbt index a0108e043f0..9fb22aca613 100644 --- a/build.sbt +++ b/build.sbt @@ -189,15 +189,15 @@ lazy val V = new { val scalameta = "4.4.2" val semanticdb = scalameta val bsp = "2.0.0-M13" - val bloop = "1.4.5-28-e52cd3ad" - val scala3 = "3.0.0-M2" + val bloop = "1.4.6-15-209c2a5c" + val scala3 = "3.0.0-M3" val bloopNightly = bloop val sbtBloop = bloop val gradleBloop = bloop val mavenBloop = bloop - val mdoc = "2.2.13" + val mdoc = "2.2.14" val scalafmt = "2.7.4" - val munit = "0.7.19" + val munit = "0.7.20" val scalafix = "0.9.24" val lsp4jV = "0.10.0" // List of supported Scala versions in SemanticDB. Needs to be manually updated @@ -217,8 +217,9 @@ lazy val V = new { def scala2Versions = nonDeprecatedScala2Versions ++ deprecatedScala2Versions // Scala 3 - def nonDeprecatedScala3Versions = Seq(scala3, "3.0.0-M1", "0.27.0-RC1") - def deprecatedScala3Versions = Seq("0.26.0") + def nonDeprecatedScala3Versions = + Seq(scala3, "3.0.0-M2", "3.0.0-M1", "0.27.0-RC1") + def deprecatedScala3Versions = Seq() def scala3Versions = nonDeprecatedScala3Versions ++ deprecatedScala3Versions def supportedScalaVersions = scala2Versions ++ scala3Versions @@ -305,7 +306,7 @@ val mtagsSettings = List( baseDirectory.in(ThisBuild).value / "mtags", scalaVersion.value ), - // @note needed to deal with issues in https://github.com/scalameta/metals/pull/2157 + // @note needed to deal with issues with dottyDoc sources in (Compile, doc) := Seq.empty, libraryDependencies ++= crossSetting( scalaVersion.value, @@ -581,7 +582,13 @@ lazy val mtest = project testSettings, sharedSettings, libraryDependencies ++= List( - "org.scalameta" %% "munit" % V.munit, + // munit had to drop support for 3.0.0-M1 and 0.27.0-RC1 + if ( + scalaVersion.value == "0.27.0-RC1" || scalaVersion.value == "3.0.0-M1" + ) + "org.scalameta" %% "munit" % "0.7.19" + else + "org.scalameta" %% "munit" % V.munit, "io.get-coursier" % "interface" % V.coursierInterfaces ), buildInfoPackage := "tests", diff --git a/metals/src/main/scala/scala/meta/internal/metals/MetalsEnrichments.scala b/metals/src/main/scala/scala/meta/internal/metals/MetalsEnrichments.scala index fbf026836b5..58c321d3551 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/MetalsEnrichments.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/MetalsEnrichments.scala @@ -585,7 +585,9 @@ object MetalsEnrichments def isSemanticdbEnabled(scalaVersion: String): Boolean = { if (ScalaVersions.isScala3Version(scalaVersion)) { - item.getOptions.asScala.exists { opt => opt == "-Ysemanticdb" } + item.getOptions.asScala.exists { opt => + opt == "-Ysemanticdb" || opt == "-Xsemanticdb" + } } else { item.getOptions.asScala.exists { opt => opt.startsWith("-Xplugin:") && opt diff --git a/metals/src/main/scala/scala/meta/internal/metals/ScalaVersions.scala b/metals/src/main/scala/scala/meta/internal/metals/ScalaVersions.scala index f2f78f9a776..b00312e1e7d 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/ScalaVersions.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/ScalaVersions.scala @@ -5,7 +5,8 @@ import scala.meta.internal.semver.SemVer object ScalaVersions { - val scala3Milestones: Set[String] = Set("3.0.0-M1", "3.0.0-M2") + def isScala3Milestone(version: String): Boolean = + version.startsWith("3.0.0-M") || version.startsWith("3.0.0-RC") /** * Non-Lightbend compilers often use a suffix, such as `-bin-typelevel-4` @@ -78,7 +79,7 @@ object ScalaVersions { ) == mtags.BuildInfo.scalaCompilerVersion def scalaBinaryVersionFromFullVersion(scalaVersion: String): String = { - if (scala3Milestones(scalaVersion)) + if (isScala3Milestone(scalaVersion)) scalaVersion else scalaVersion.split('.').take(2).mkString(".") diff --git a/mtags/src/main/scala-3/scala/meta/internal/pc/Scala3CompilerWrapper.scala b/mtags/src/main/scala-3/scala/meta/internal/pc/Scala3CompilerWrapper.scala index ab2fe900e2a..db7ce5a9986 100644 --- a/mtags/src/main/scala-3/scala/meta/internal/pc/Scala3CompilerWrapper.scala +++ b/mtags/src/main/scala-3/scala/meta/internal/pc/Scala3CompilerWrapper.scala @@ -12,8 +12,8 @@ class Scala3CompilerWrapper(driver: InteractiveDriver) override def compiler(): InteractiveDriver = driver override def resetReporter(): Unit = { - given ctx as Context = driver.currentCtx - ctx.reporter.removeBufferedMessages + val ctx = driver.currentCtx + ctx.reporter.removeBufferedMessages(using ctx) } override def reporterAccess: ReporterAccess[StoreReporter] = diff --git a/mtags/src/main/scala-3/scala/meta/internal/pc/ScalaPresentationCompiler.scala b/mtags/src/main/scala-3/scala/meta/internal/pc/ScalaPresentationCompiler.scala index 58a39a4db77..a67933d6287 100644 --- a/mtags/src/main/scala-3/scala/meta/internal/pc/ScalaPresentationCompiler.scala +++ b/mtags/src/main/scala-3/scala/meta/internal/pc/ScalaPresentationCompiler.scala @@ -119,7 +119,7 @@ case class ScalaPresentationCompiler( val sourceFile = CompilerInterfaces.toSource(params.uri, params.text) driver.run(uri, sourceFile) - given ctx as Context = driver.currentCtx + val ctx = driver.currentCtx val pos = sourcePosition(driver, params, uri) val items = driver.compilationUnits.get(uri) match { case Some(unit) => @@ -128,7 +128,7 @@ case class ScalaPresentationCompiler( } new CompletionList( /*isIncomplete = */ false, - items.map(completionItem).asJava + items.map(completionItem(_)(using ctx)).asJava ) } } @@ -139,17 +139,17 @@ case class ScalaPresentationCompiler( params.token ) { access => val driver = access.compiler() - given ctx as Context = driver.currentCtx + val ctx = driver.currentCtx val uri = params.uri val sourceFile = CompilerInterfaces.toSource(params.uri, params.text) driver.run(uri, sourceFile) val pos = sourcePosition(driver, params, uri) - val path = Interactive.pathTo(driver.openedTrees(uri), pos) + val path = Interactive.pathTo(driver.openedTrees(uri), pos)(using ctx) val definitions = Interactive.findDefinitions(path, pos, driver).toList DefinitionResultImpl( "", - definitions.flatMap(d => location(d.namePos)).asJava + definitions.flatMap(d => location(d.namePos(using ctx))).asJava ) } @@ -253,22 +253,22 @@ case class ScalaPresentationCompiler( val sourceFile = CompilerInterfaces.toSource(params.uri, params.text) driver.run(uri, sourceFile) - given ctx as Context = driver.currentCtx + val ctx = driver.currentCtx val pos = sourcePosition(driver, params, uri) val trees = driver.openedTrees(uri) - val path = Interactive.pathTo(trees, pos) - val tp = Interactive.enclosingType(trees, pos) - val tpw = tp.widenTermRefExpr + val path = Interactive.pathTo(trees, pos)(using ctx) + val tp = Interactive.enclosingType(trees, pos)(using ctx) + val tpw = tp.widenTermRefExpr(using ctx) - if (tp.isError || tpw == NoType || tpw.isError) + if (tp.isError(using ctx) || tpw == NoType || tpw.isError(using ctx)) ju.Optional.empty() else { - Interactive.enclosingSourceSymbols(path, pos) match { + Interactive.enclosingSourceSymbols(path, pos)(using ctx) match { case Nil => ju.Optional.empty() case symbols => - val printer = SymbolPrinter() - val docComments = symbols.flatMap(ParsedComment.docOf) + val printer = SymbolPrinter()(using ctx) + val docComments = symbols.flatMap(ParsedComment.docOf(_)(using ctx)) val keywordName = symbols.headOption.map { symbol => printer.fullDefinition( symbol, @@ -279,7 +279,7 @@ case class ScalaPresentationCompiler( tpw match { // https://github.com/lampepfl/dotty/issues/8891 case _: ImportType => - printer.typeString(symbol.typeRef) + printer.typeString(symbol.paramRef(using ctx)) case _ => printer.typeString(tpw) } @@ -288,7 +288,7 @@ case class ScalaPresentationCompiler( keywordName, typeString, docComments - ) + )(using ctx) ju.Optional.of(new Hover(content)) } } @@ -315,19 +315,19 @@ case class ScalaPresentationCompiler( val sourceFile = CompilerInterfaces.toSource(params.uri, params.text) driver.run(uri, sourceFile) - given ctx as Context = driver.currentCtx + val ctx = driver.currentCtx val pos = sourcePosition(driver, params, uri) val trees = driver.openedTrees(uri) // @tgodzik tpd.TypeApply doesn't seem to be handled here val path = - Interactive.pathTo(trees, pos).dropWhile(!_.isInstanceOf[tpd.Apply]) + Interactive.pathTo(trees, pos)(using ctx).dropWhile(!_.isInstanceOf[tpd.Apply]) val (paramN, callableN, alternatives) = - Signatures.callInfo(path, pos.span) + Signatures.callInfo(path, pos.span)(using ctx) - val signatureInfos = alternatives.flatMap(Signatures.toSignature) + val signatureInfos = alternatives.flatMap(Signatures.toSignature(_)(using ctx)) new SignatureHelp( signatureInfos.map(signatureToSignatureInformation).asJava, callableN, diff --git a/project/build.properties b/project/build.properties index c19c768d694..c06db1bb2ea 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.4.2 +sbt.version=1.4.5 diff --git a/project/plugins.sbt b/project/plugins.sbt index eac39326a03..d062c8a2c8c 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -4,7 +4,7 @@ addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.5") addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.13") addSbtPlugin("org.scalameta" % "sbt-munit" % "0.7.19") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") -addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.4.6") +addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.5.1") addSbtPlugin("com.github.reibitto" % "sbt-welcome" % "0.2.1") libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value diff --git a/sbt-metals/src/main/scala/scala/meta/metals/MetalsPlugin.scala b/sbt-metals/src/main/scala/scala/meta/metals/MetalsPlugin.scala index 8c417686d09..4b59218a5ca 100644 --- a/sbt-metals/src/main/scala/scala/meta/metals/MetalsPlugin.scala +++ b/sbt-metals/src/main/scala/scala/meta/metals/MetalsPlugin.scala @@ -46,8 +46,15 @@ object MetalsPlugin extends AutoPlugin { } else { val sdbOptions = semanticdbOptions.value (old.toVector ++ sdbOptions ++ - (if (ScalaInstance.isDotty(versionOfScala)) Some("-Ysemanticdb") - else None)).distinct + (if (ScalaInstance.isDotty(versionOfScala)) { + if ( + versionOfScala == "3.0.0-M1" || versionOfScala == "3.0.0-M2" || versionOfScala + .startsWith("0.") + ) + Some("-Ysemanticdb") + else + Some("-Xsemanticdb") + } else None)).distinct } }, semanticdbEnabled := { diff --git a/tests/cross/src/main/scala/tests/pc/BaseHoverSuite.scala b/tests/cross/src/main/scala/tests/pc/BaseHoverSuite.scala index 0e8201ffc84..15395dfb7d2 100644 --- a/tests/cross/src/main/scala/tests/pc/BaseHoverSuite.scala +++ b/tests/cross/src/main/scala/tests/pc/BaseHoverSuite.scala @@ -7,6 +7,7 @@ import scala.meta.internal.metals.CompilerOffsetParams import scala.meta.internal.mtags.MtagsEnrichments._ import munit.Location +import munit.TestOptions import tests.BasePCSuite import tests.RangeReplace import tests.TestHovers @@ -17,16 +18,16 @@ abstract class BaseHoverSuite with RangeReplace { def check( - name: String, + testOpt: TestOptions, original: String, expected: String, includeRange: Boolean = false, automaticPackage: Boolean = true, compat: Map[String, String] = Map.empty )(implicit loc: Location): Unit = { - test(name) { + test(testOpt) { val filename = "Hover.scala" - val pkg = scala.meta.Term.Name(name).syntax + val pkg = scala.meta.Term.Name(testOpt.name).syntax val noRange = original .replace("<<", "") .replace(">>", "") diff --git a/tests/cross/src/test/scala/tests/pc/CancelCompletionSuite.scala b/tests/cross/src/test/scala/tests/pc/CancelCompletionSuite.scala index 2a22be7d9fe..4bf9b2aa2aa 100644 --- a/tests/cross/src/test/scala/tests/pc/CancelCompletionSuite.scala +++ b/tests/cross/src/test/scala/tests/pc/CancelCompletionSuite.scala @@ -95,6 +95,9 @@ class CancelCompletionSuite extends BaseCompletionSuite { "3.0.0-M2" -> """|assert(assertion: Boolean @InlineParam): Unit |""".stripMargin, + "3.0.0-M3" -> + """|assert(assertion: Boolean @InlineParam): Unit + |""".stripMargin, "3.0" -> """|assert(assertion: Boolean @InlineParam): Unit |assertFail(message: => Any): Nothing diff --git a/tests/cross/src/test/scala/tests/pc/CompletionSuite.scala b/tests/cross/src/test/scala/tests/pc/CompletionSuite.scala index 65a9471f2fe..2bb37e74c67 100644 --- a/tests/cross/src/test/scala/tests/pc/CompletionSuite.scala +++ b/tests/cross/src/test/scala/tests/pc/CompletionSuite.scala @@ -424,7 +424,10 @@ class CompletionSuite extends BaseCompletionSuite { | class Inner |} |""".stripMargin, - "" + "", + compat = Map( + "3.0.0-M3" -> "Inner: a.Outer.Inner$" + ) ) check( diff --git a/tests/mtest/src/main/scala/tests/BaseSuite.scala b/tests/mtest/src/main/scala/tests/BaseSuite.scala index 5cfee826752..c5dbd996f93 100644 --- a/tests/mtest/src/main/scala/tests/BaseSuite.scala +++ b/tests/mtest/src/main/scala/tests/BaseSuite.scala @@ -68,8 +68,7 @@ class BaseSuite extends munit.FunSuite with Assertions { .orElse { compat.collect { // fallback to 3.0 for 0. pre-release versions - case (ver, code) - if scalaVersion.startsWith("0.") && ver.startsWith("3.") => + case (ver, code) if scalaVersion.startsWith("0.") && ver == "3.0" => code }.headOption } diff --git a/tests/slow/src/test/scala/tests/sbt/SbtBloopLspSuite.scala b/tests/slow/src/test/scala/tests/sbt/SbtBloopLspSuite.scala index 83801f34ad9..9fdd37f0621 100644 --- a/tests/slow/src/test/scala/tests/sbt/SbtBloopLspSuite.scala +++ b/tests/slow/src/test/scala/tests/sbt/SbtBloopLspSuite.scala @@ -454,7 +454,7 @@ class SbtBloopLspSuite "build.sbt", "sc@@alaVersion := \"2.12.11\"", ".metals/readonly/sbt/Keys.scala", - expectedLine = 189 + expectedLine = 190 ) } yield () }