Skip to content

Commit

Permalink
chore: Add support for Scala 2.13.11
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik committed Jun 4, 2023
1 parent b7cfce5 commit f7b9984
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 34 deletions.
1 change: 1 addition & 0 deletions bin/test-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ coursier fetch \
org.scalameta:mtags_2.13.8:$version \
org.scalameta:mtags_2.13.9:$version \
org.scalameta:mtags_2.13.10:$version \
org.scalameta:mtags_2.13.11:$version \
org.scalameta:mtags_2.12.9:$version \
org.scalameta:mtags_2.12.10:$version \
org.scalameta:mtags_2.12.11:$version \
Expand Down
5 changes: 3 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,10 @@ val mtagsSettings = List(
val current = (Compile / unmanagedSourceDirectories).value
val base = (Compile / sourceDirectory).value
val regex = "(\\d+)\\.(\\d+)\\.(\\d+).*".r
// For scala 2.13.9/10 we need to have a special Compat.scala
// For scala +2.13.9 we need to have a special Compat.scala
// For this case filter out `scala-2.13` directory that comes by default
if (scalaVersion.value == "2.13.9" || scalaVersion.value == "2.13.10")
val scalaVersionsWithSpecialCompat = Set("2.13.9", "2.13.10", "2.13.11")
if (scalaVersionsWithSpecialCompat(scalaVersion.value))
current.filter(f => f.getName() != "scala-2.13")
else
current
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,7 @@ class MetalsLspService(
override def completionItemResolve(
item: CompletionItem
): CompletableFuture[CompletionItem] =
CancelTokens.future { token =>
CancelTokens.future { _ =>
if (clientConfig.isCompletionItemResolve) {
compilers.completionItemResolve(item)
} else {
Expand Down Expand Up @@ -1784,7 +1784,7 @@ class MetalsLspService(
override def foldingRange(
params: FoldingRangeRequestParams
): CompletableFuture[util.List[FoldingRange]] = {
CancelTokens.future { token =>
CancelTokens.future { _ =>
val path = params.getTextDocument().getUri().toAbsolutePath
if (path.isScala)
parseTrees.currentFuture.map(_ =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ object MtagsResolver {
private val removedScalaVersions = Map(
"2.13.1" -> "0.11.10",
"2.13.2" -> "0.11.10",
"2.13.3" -> "0.11.12",
"2.12.9" -> "0.11.10",
"3.0.0" -> "0.11.10",
"3.0.1" -> "0.11.10",
Expand Down
26 changes: 26 additions & 0 deletions mtags/src/main/scala-2.13.11/meta/internal/pc/Compat.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package scala.meta.internal.pc

import scala.reflect.internal.Reporter
import scala.tools.nsc.reporters.StoreReporter

trait Compat { this: MetalsGlobal =>
def metalsFunctionArgTypes(tpe: Type): List[Type] =
definitions.functionOrPfOrSamArgTypes(tpe)

val AssignOrNamedArg: NamedArgExtractor = NamedArg

def storeReporter(r: Reporter): Option[StoreReporter] =
r match {
case s: StoreReporter => Some(s)
case _ => None
}

def isAliasCompletion(m: Member): Boolean = m match {
case tm: TypeMember => tm.aliasInfo.nonEmpty
case sm: ScopeMember => sm.aliasInfo.nonEmpty
case _ => false
}

def constantType(c: ConstantType): ConstantType =
if (c.value.isSuitableLiteralType) LiteralType(c.value) else c
}
10 changes: 6 additions & 4 deletions project/V.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import sbt._
object V {
val scala210 = "2.10.7"
val scala211 = "2.11.12"
val scala212 = "2.12.17"
val scala213 = "2.13.10"
val scala3 = "3.2.2"
val scala3RC: Option[String] = Some("3.3.0-RC4")
val scala212 = "2.12.18"
val scala213 = "2.13.11"
val scala3 = "3.3.0"
val scala3RC: Option[String] = Some("3.3.1-RC1")
val sbtScala = "2.12.16"
val ammonite212Version = "2.12.17"
val ammonite213Version = "2.13.10"
Expand Down Expand Up @@ -71,6 +71,7 @@ object V {
"2.12.12",
"2.12.13",
"2.13.3",
"2.12.14",
"2.13.4",
"2.13.5",
"2.13.6",
Expand All @@ -85,6 +86,7 @@ object V {
"2.13.7",
"2.13.8",
"2.13.9",
"2.13.10",
)
def scala2Versions = nonDeprecatedScala2Versions ++ deprecatedScala2Versions

Expand Down
25 changes: 25 additions & 0 deletions tests/cross/src/test/scala/tests/pc/CompletionDocSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,31 @@ class CompletionDocSuite extends BaseCompletionSuite {
|StringBuilder(capacity: Int): StringBuilder
|StringBuilder(initCapacity: Int, initValue: String): StringBuilder
|""".stripMargin,
"2.13.11" ->
"""|> A builder of `String` which is also a mutable sequence of characters.
|
| This class provides an API mostly compatible with `java.lang.StringBuilder`,
| except where there are conflicts with the Scala collections API, such as the `reverse` method:
| [reverse](reverse) produces a new `StringBuilder`, and [reverseInPlace](reverseInPlace) mutates this builder.
|
| Mutating operations return either `this.type`, i.e., the current builder, or `Unit`.
|
| Other methods extract data or information from the builder without mutating it.
|
| The distinction is also reflected in naming conventions used by collections,
| such as `append`, which mutates, and `appended`, which does not, or `reverse`,
| which does not mutate, and `reverseInPlace`, which does.
|
| The `String` result may be obtained using either `result()` or `toString`.
|
| $multipleResults
|
|
|**See**
|- ["Scala's Collection Library overview"](https://docs.scala-lang.org/overviews/collections-2.13/concrete-mutable-collection-classes.html#stringbuilders)
| section on `StringBuilders` for more information.
|StringBuilder scala.collection.mutable
|""".stripMargin,
),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class CompletionScalaCliSuite extends BaseCompletionSuite {
check(
"plugin".tag(
IgnoreScalaVersion(version =>
Set("2.12.18")(version) ||
Set("2.12.16", "2.12.18", "2.13.11")(version) ||
version.contains(
"NIGHTLY"
) || version.contains(
Expand Down
9 changes: 9 additions & 0 deletions tests/cross/src/test/scala/tests/pc/CompletionSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,15 @@ class CompletionSuite extends BaseCompletionSuite {
|implicitConversions scala.languageFeature
|""".stripMargin,
topLines = Some(5),
compat = Map(
"2.13.11" ->
"""|dynamics scala.languageFeature
|existentials scala.languageFeature
|experimental scala.languageFeature
|implicitConversions scala.languageFeature
|postfixOps scala.languageFeature
|""".stripMargin
),
)

check(
Expand Down
53 changes: 28 additions & 25 deletions tests/cross/src/test/scala/tests/pc/SignatureHelpDocSuite.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tests.pc

import tests.BaseSignatureHelpSuite
import scala.meta.internal.mtags.BuildInfo

class SignatureHelpDocSuite extends BaseSignatureHelpSuite {

Expand Down Expand Up @@ -132,6 +133,8 @@ class SignatureHelpDocSuite extends BaseSignatureHelpSuite {
|""".stripMargin,
),
)

val addedSpace = if (BuildInfo.scalaCompilerVersion == "2.13.11") "" else " "
checkDoc(
"curry3",
"""
Expand Down Expand Up @@ -171,31 +174,31 @@ class SignatureHelpDocSuite extends BaseSignatureHelpSuite {
|""".stripMargin,
compat = Map(
"2.13" ->
"""|Applies a binary operator to a start value and all elements of this collection,
| going left to right.
|
| Note: will not terminate for infinite-sized collections.
| Note: might return different results for different runs, unless the
|underlying collection type is ordered or the operator is associative
|and commutative.
|
|
|**Type Parameters**
|- `B`: the result type of the binary operator.
|
|**Parameters**
|- `z`: the start value.
|- `op`: the binary operator.
|
|**Returns:** the result of inserting `op` between consecutive elements of this collection,
| going left to right with the start value `z` on the left:
| `op(...op(z, x), x, ..., x)` where `x, ..., x`
| are the elements of this collection.
| Returns `z` if this collection is empty.
|foldLeft[B](z: B)(op: (B, Int) => B): B
| ^^^^^^^^^^^^^^^^^
| @param op (Int, Int) => Int
|""".stripMargin,
s"""|Applies a binary operator to a start value and all elements of this collection,
| going left to right.
|
| Note: will not terminate for infinite-sized collections.
| Note: might return different results for different runs, unless the
|underlying collection type is ordered or the operator is associative
|and commutative.
|
|
|**Type Parameters**
|- `B`: the result type of the binary operator.
|
|**Parameters**
|- `z`: the start value.
|- `op`: the binary operator.
|
|**Returns:** the result of inserting `op` between consecutive elements of this collection,
| going left to right with the start value `z` on the left:
| `op(...op(z, x), x, ..., x)` where `x, ..., x`
| ${addedSpace}are the elements of this collection.
| Returns `z` if this collection is empty.
|foldLeft[B](z: B)(op: (B, Int) => B): B
| ^^^^^^^^^^^^^^^^^
| @param op (Int, Int) => Int
|""".stripMargin,
"3" ->
"""|Applies a binary operator to a start value and all elements of this collection,
| going left to right.
Expand Down

0 comments on commit f7b9984

Please sign in to comment.