From 3c9ff69cbe6a4ed66438a624c68f255ab59d7b2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Doeraene?= Date: Wed, 24 Jul 2024 12:51:11 +0200 Subject: [PATCH] Upgrade to Scala 3.4.2. And apply changes due to https://github.com/scala/scala3/pull/19761 --- build.sbt | 2 +- .../test/scala/tastyquery/PrintersTest.scala | 22 ++++++++++++++----- .../test/scala/tastyquery/ReadTreeSuite.scala | 18 ++++++++------- .../scala/tastyquery/SignatureSuite.scala | 6 +++-- .../scala/simple_trees/AccessModifiers.scala | 2 +- 5 files changed, 32 insertions(+), 18 deletions(-) diff --git a/build.sbt b/build.sbt index 2138d228..4aebcc3b 100644 --- a/build.sbt +++ b/build.sbt @@ -3,7 +3,7 @@ import sbt.internal.util.ManagedLogger import org.scalajs.jsenv.nodejs.NodeJSEnv -val usedScalaCompiler = "3.4.0" +val usedScalaCompiler = "3.4.2" val usedTastyRelease = usedScalaCompiler val scala2Version = "2.13.14" diff --git a/tasty-query/shared/src/test/scala/tastyquery/PrintersTest.scala b/tasty-query/shared/src/test/scala/tastyquery/PrintersTest.scala index e7d6eb86..eb0e8426 100644 --- a/tasty-query/shared/src/test/scala/tastyquery/PrintersTest.scala +++ b/tasty-query/shared/src/test/scala/tastyquery/PrintersTest.scala @@ -211,7 +211,11 @@ class PrintersTest extends UnrestrictedUnpicklingSuite: ) val MatchTypeClass = ctx.findTopLevelClass("simple_trees.MatchType") - testShowBasicMember(MatchTypeClass, typeName("MT"), "type MT[X] = X match { case Int => String }") + testShowBasicMember( + MatchTypeClass, + typeName("MT"), + "type MT[X] <: scala.Predef.String = X match { case Int => String }" + ) testShowBasicMember( MatchTypeClass, typeName("MTWithBound"), @@ -220,9 +224,14 @@ class PrintersTest extends UnrestrictedUnpicklingSuite: testShowBasicMember( MatchTypeClass, typeName("MTWithWildcard"), - "type MTWithWildcard[X] = X match { case _ => Int }" + "type MTWithWildcard[X] <: scala.Int = X match { case _ => Int }" + ) + // The `<: t` is completely wrong. See https://github.com/scala/scala3/issues/21256 + testShowBasicMember( + MatchTypeClass, + typeName("MTWithBind"), + "type MTWithBind[X] <: t = X match { case List[t] => t }" ) - testShowBasicMember(MatchTypeClass, typeName("MTWithBind"), "type MTWithBind[X] = X match { case List[t] => t }") } testWithContext("multiline tree printers") { @@ -286,7 +295,7 @@ class PrintersTest extends UnrestrictedUnpicklingSuite: testShowMultilineMember( MatchTypeClass, typeName("MT"), - """type MT[X] = X match { + """type MT[X] <: scala.Predef.String = X match { | case Int => String |}""".stripMargin ) @@ -300,14 +309,15 @@ class PrintersTest extends UnrestrictedUnpicklingSuite: testShowMultilineMember( MatchTypeClass, typeName("MTWithWildcard"), - """type MTWithWildcard[X] = X match { + """type MTWithWildcard[X] <: scala.Int = X match { | case _ => Int |}""".stripMargin ) + // The `<: t` is completely wrong. See https://github.com/scala/scala3/issues/21256 testShowMultilineMember( MatchTypeClass, typeName("MTWithBind"), - """type MTWithBind[X] = X match { + """type MTWithBind[X] <: t = X match { | case List[t] => t |}""".stripMargin ) diff --git a/tasty-query/shared/src/test/scala/tastyquery/ReadTreeSuite.scala b/tasty-query/shared/src/test/scala/tastyquery/ReadTreeSuite.scala index bbe4c29f..26da6e46 100644 --- a/tasty-query/shared/src/test/scala/tastyquery/ReadTreeSuite.scala +++ b/tasty-query/shared/src/test/scala/tastyquery/ReadTreeSuite.scala @@ -1904,8 +1904,8 @@ class ReadTreeSuite extends RestrictedUnpicklingSuite { List(TypeParam(SimpleTypeName("X"), NothingAnyTypeBoundsTree(), _)), TypeAliasDefinitionTree( MatchTypeTree( - // No bound on the match result - TypeWrapper(TypeRefInternal(ScalaPackageRef(), tpnme.Any)), + // No bound on the match result -- inferred to be String since 3.4.2 + TypeWrapper(TypeRefInternal(_, tpnme.String)), TypeIdent(SimpleTypeName("X")), List(TypeCaseDef(TypeIdent(SimpleTypeName("Int")), TypeIdent(SimpleTypeName("String")))) ) @@ -1946,8 +1946,8 @@ class ReadTreeSuite extends RestrictedUnpicklingSuite { List(TypeParam(SimpleTypeName("X"), NothingAnyTypeBoundsTree(), _)), TypeAliasDefinitionTree( MatchTypeTree( - // No bound on the match result - TypeWrapper(TypeRefInternal(ScalaPackageRef(), tpnme.Any)), + // No bound on the match result -- inferred since 3.4.2 + TypeWrapper(_), TypeIdent(SimpleTypeName("X")), List(TypeCaseDef(TypeIdent(tpnme.Wildcard), TypeIdent(SimpleTypeName("Int")))) ) @@ -1965,8 +1965,8 @@ class ReadTreeSuite extends RestrictedUnpicklingSuite { List(TypeParam(SimpleTypeName("X"), NothingAnyTypeBoundsTree(), _)), TypeAliasDefinitionTree( MatchTypeTree( - // No bound on the match result - TypeWrapper(TypeRefInternal(ScalaPackageRef(), tpnme.Any)), + // No bound on the match result -- inferred since 3.4.2 + TypeWrapper(_), TypeIdent(SimpleTypeName("X")), List( TypeCaseDef( @@ -1995,7 +1995,8 @@ class ReadTreeSuite extends RestrictedUnpicklingSuite { Select(rhs, SignedName(SimpleName("$asInstanceOf$"), _, _)), TypeWrapper( ty.MatchType( - TypeRefInternal(ScalaPackageRef(), SimpleTypeName("Any")), + // No bound on the match result -- inferred since 3.4.2 + _, TypeRefInternal(_, xRef), List( ty.MatchTypeCase( @@ -2026,7 +2027,8 @@ class ReadTreeSuite extends RestrictedUnpicklingSuite { Select(rhs, SignedName(SimpleName("$asInstanceOf$"), _, _)), TypeWrapper( ty.MatchType( - TypeRefInternal(ScalaPackageRef(), SimpleTypeName("Any")), + // No bound on the match result -- inferred since 3.4.2 + _, TypeRefInternal(_, xRef), List( ty.MatchTypeCase( diff --git a/tasty-query/shared/src/test/scala/tastyquery/SignatureSuite.scala b/tasty-query/shared/src/test/scala/tastyquery/SignatureSuite.scala index 261e9a4e..19047b6f 100644 --- a/tasty-query/shared/src/test/scala/tastyquery/SignatureSuite.scala +++ b/tasty-query/shared/src/test/scala/tastyquery/SignatureSuite.scala @@ -408,7 +408,8 @@ class SignatureSuite extends UnrestrictedUnpicklingSuite: val MatchType = ctx.findTopLevelClass("simple_trees.MatchType") val unboundUnreducibleSig = MatchType.findNonOverloadedDecl(termName("unboundUnreducibleSig")) - assertSigned(unboundUnreducibleSig, "(1,java.lang.Object):java.lang.Object") + // Was "(1,java.lang.Object):java.lang.Object" < 3.4.2 + assertSigned(unboundUnreducibleSig, "(1,java.lang.Object):java.lang.String") val unboundReducibleSig = MatchType.findNonOverloadedDecl(termName("unboundReducibleSig")) assertSigned(unboundReducibleSig, "(1,scala.Int):java.lang.String") @@ -421,7 +422,8 @@ class SignatureSuite extends UnrestrictedUnpicklingSuite: // this one is suspicious, but it is what dotc does (I expected `Object` instead of `Object[]`) val arrayOfUnboundUnreducibleSig = MatchType.findNonOverloadedDecl(termName("arrayOfUnboundUnreducibleSig")) - assertSigned(arrayOfUnboundUnreducibleSig, "(1,java.lang.Object):java.lang.Object[]") + // Was "(1,java.lang.Object):java.lang.Object[]" < 3.4.2 + assertSigned(arrayOfUnboundUnreducibleSig, "(1,java.lang.Object):java.lang.String[]") val arrayOfUnboundReducibleSig = MatchType.findNonOverloadedDecl(termName("arrayOfUnboundReducibleSig")) assertSigned(arrayOfUnboundReducibleSig, "(1,scala.Int):java.lang.String[]") diff --git a/test-sources/src/main/scala/simple_trees/AccessModifiers.scala b/test-sources/src/main/scala/simple_trees/AccessModifiers.scala index 5ef7824b..e8e908b7 100644 --- a/test-sources/src/main/scala/simple_trees/AccessModifiers.scala +++ b/test-sources/src/main/scala/simple_trees/AccessModifiers.scala @@ -2,7 +2,7 @@ package simple_trees import scala.annotation.nowarn -@nowarn("msg=The \\[this\\] qualifier will be deprecated") +@nowarn("msg=Ignoring \\[this\\] qualifier") class AccessModifiers( localParam: Int, private[this] val privateThisParam: Int,