Repository: scalameta/scalameta
Pull request #2809 (2022-08-22 00:38:44)

Dialect: add intermediate scala3 dialects
Helps with #2807.

dos65: Honestly, I still not fully understand the point of that at this time. 

I think right now there is no need in splitting it on `3.0` and `3.1`. `withAllowUnderscoreAsTypePlaceholder` (with a different name) was always enabled for scala3 and I think there were no issues with that. 
As I understand `3.2` will be an LTS version. So `3.0` and `3.1` are close to the end of life.
I can't imagine the case when there will be a need in using these dialects. 

However, I think we will have to do the similar thing at the time when there will be `3.3`
tgodzik: > However, I think we will have to do the similar thing at the time when there will be 3.3

That's mostly to prepare for that, though we don't have to merge it yet.

Patch:
diff --git a/scalameta/dialects/shared/src/main/scala/scala/meta/Dialect.scala b/scalameta/dialects/shared/src/main/scala/scala/meta/Dialect.scala
index 41086f7f7..7cc2dc185 100644
--- a/scalameta/dialects/shared/src/main/scala/scala/meta/Dialect.scala
+++ b/scalameta/dialects/shared/src/main/scala/scala/meta/Dialect.scala
@@ -769,6 +769,9 @@ object Dialect extends InternalDialect {
   }
   private lazy val standardPairs = Seq[sourcecode.Text[Dialect]](
     Dotty,
+    Scala30,
+    Scala31,
+    Scala32,
     Scala3,
     Paradise211,
     Paradise212,
diff --git a/scalameta/dialects/shared/src/main/scala/scala/meta/dialects/package.scala b/scalameta/dialects/shared/src/main/scala/scala/meta/dialects/package.scala
index 988088d9d..ad50b24b4 100644
--- a/scalameta/dialects/shared/src/main/scala/scala/meta/dialects/package.scala
+++ b/scalameta/dialects/shared/src/main/scala/scala/meta/dialects/package.scala
@@ -102,7 +102,7 @@ package object dialects {
   implicit val ParadiseTypelevel212 = Typelevel212
     .withAllowInlineMods(true)
 
-  implicit val Scala3 = Scala213
+  implicit val Scala30 = Scala213
     // there 3 different ways to specify vargs, some will be removed in future Scala 3 versions
     .withAllowAtForExtractorVarargs(true) // both @ and : work currently for Scala 3
     .withAllowColonForExtractorVarargs(true) // both @ and : work currently for Scala 3
@@ -142,10 +142,16 @@ package object dialects {
     .withAllowStarWildcardImport(true)
     .withAllowProcedureSyntax(false)
     .withAllowDoWhile(false)
-    .withAllowUnderscoreAsTypePlaceholder(true)
     .withUseInfixTypePrecedence(true)
     .withAllowInfixOperatorAfterNL(true)
 
+  implicit val Scala31 = Scala30
+
+  implicit val Scala32 = Scala31
+    .withAllowUnderscoreAsTypePlaceholder(true)
+
+  implicit val Scala3 = Scala32
+
   @deprecated("Use Scala3 instead", "4.4.2")
   implicit val Dotty = Scala3
 


Test patch:
diff --git a/tests/jvm/src/test/scala-2.13/scala/meta/tests/api/SurfaceSuite.scala b/tests/jvm/src/test/scala-2.13/scala/meta/tests/api/SurfaceSuite.scala
index 7e1b86188..7948f0459 100644
--- a/tests/jvm/src/test/scala-2.13/scala/meta/tests/api/SurfaceSuite.scala
+++ b/tests/jvm/src/test/scala-2.13/scala/meta/tests/api/SurfaceSuite.scala
@@ -102,6 +102,9 @@ class SurfaceSuite extends FunSuite {
       |scala.meta.dialects.Scala213 *
       |scala.meta.dialects.Scala213Source3 *
       |scala.meta.dialects.Scala3 *
+      |scala.meta.dialects.Scala30 *
+      |scala.meta.dialects.Scala31 *
+      |scala.meta.dialects.Scala32 *
       |scala.meta.dialects.Typelevel211 *
       |scala.meta.dialects.Typelevel212 *
       |scala.meta.inputs
diff --git a/tests/shared/src/test/scala/scala/meta/tests/prettyprinters/PublicSuite.scala b/tests/shared/src/test/scala/scala/meta/tests/prettyprinters/PublicSuite.scala
index a6b017745..7e9681445 100644
--- a/tests/shared/src/test/scala/scala/meta/tests/prettyprinters/PublicSuite.scala
+++ b/tests/shared/src/test/scala/scala/meta/tests/prettyprinters/PublicSuite.scala
@@ -97,6 +97,18 @@ class PublicSuite extends TreeSuiteBase {
     assertNoDiff(scala.meta.dialects.Scala3.toString, "Scala3")
   }
 
+  test("scala.meta.dialects.Scala30.toString") {
+    assertNoDiff(scala.meta.dialects.Scala30.toString, "Scala31")
+  }
+
+  test("scala.meta.dialects.Scala31.toString") {
+    assertNoDiff(scala.meta.dialects.Scala31.toString, "Scala31")
+  }
+
+  test("scala.meta.dialects.Scala32.toString") {
+    assertNoDiff(scala.meta.dialects.Scala32.toString, "Scala3")
+  }
+
   test("scala.meta.dialects.Dotty.toString") {
     // NOTE(olafur): `Dotty` and `Scala3` are identical so it's expected that
     // `toString` returns "Scala3" instead of "Dotty".