From c3648065184045fe2ce4eaf26e25fb115a329203 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 6 Jun 2023 17:05:44 +0200 Subject: [PATCH 1/2] Revert "Inline _N case class product members under -Yscala2-stdlib" These product members are only in the bytecode. This reverts commit 8c58cbfe39f4ef99d8900849c73206b3944c4cd8. --- compiler/src/dotty/tools/dotc/ast/Desugar.scala | 3 +-- project/MiMaFilters.scala | 6 ++++++ stdlib-bootstrapped/test/Main.scala | 9 --------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 6949c9ed691a..e0791f313970 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -664,8 +664,7 @@ object desugar { // new C[...](p1, ..., pN)(moreParams) val (caseClassMeths, enumScaffolding) = { def syntheticProperty(name: TermName, tpt: Tree, rhs: Tree) = - val mods = if caseClassInScala2StdLib then synthetic | Inline else synthetic - DefDef(name, Nil, tpt, rhs).withMods(mods) + DefDef(name, Nil, tpt, rhs).withMods(synthetic) def productElemMeths = val caseParams = derivedVparamss.head.toArray diff --git a/project/MiMaFilters.scala b/project/MiMaFilters.scala index a7d449c48ebc..4c3caceaf253 100644 --- a/project/MiMaFilters.scala +++ b/project/MiMaFilters.scala @@ -139,6 +139,12 @@ object MiMaFilters { // Companion module class: Missing type java.io.Serializable ProblemFilters.exclude[MissingTypesProblem]("scala.*$"), + // Case class product accessors + ProblemFilters.exclude[DirectMissingMethodProblem]("scala.*._1"), + ProblemFilters.exclude[DirectMissingMethodProblem]("scala.*._2"), + ProblemFilters.exclude[DirectMissingMethodProblem]("scala.*._3"), + ProblemFilters.exclude[DirectMissingMethodProblem]("scala.*._4"), + // abstract method elemTag()scala.reflect.ClassTag in class scala.collection.mutable.ArraySeq does not have a correspondent in other version ProblemFilters.exclude[DirectAbstractMethodProblem]("scala.collection.immutable.ArraySeq.elemTag"), ProblemFilters.exclude[DirectAbstractMethodProblem]("scala.collection.mutable.ArraySeq.elemTag"), diff --git a/stdlib-bootstrapped/test/Main.scala b/stdlib-bootstrapped/test/Main.scala index 7f3bd33af8df..6d6df4331356 100644 --- a/stdlib-bootstrapped/test/Main.scala +++ b/stdlib-bootstrapped/test/Main.scala @@ -15,7 +15,6 @@ object HelloWorld: testScala2UnapplySignatures() testScala2ObjectParents() - testScala2ProductMembers() } def testScala2UnapplySignatures() = { @@ -32,11 +31,3 @@ object HelloWorld: assert(!typeChecks("Either: scala.deriving.Mirror.Sum")) assert(!typeChecks("Either: scala.deriving.Mirror")) } - def testScala2ProductMembers() = { - Some(1)._1 - Right(1)._1 - (1, 2)._1 - (1, 2)._2 - ::(1, Nil)._1 - ::(1, Nil)._2 - } From 9547198f5e81461218e7bbf351ce698ba58cf67c Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Fri, 30 Jun 2023 17:48:07 +0200 Subject: [PATCH 2/2] Add test case that shows the current problem with product members --- stdlib-bootstrapped/test/Main.scala | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/stdlib-bootstrapped/test/Main.scala b/stdlib-bootstrapped/test/Main.scala index 6d6df4331356..1ac8203cbdeb 100644 --- a/stdlib-bootstrapped/test/Main.scala +++ b/stdlib-bootstrapped/test/Main.scala @@ -15,6 +15,7 @@ object HelloWorld: testScala2UnapplySignatures() testScala2ObjectParents() + testScala2CaseClassUnderscoreMembers() } def testScala2UnapplySignatures() = { @@ -31,3 +32,8 @@ object HelloWorld: assert(!typeChecks("Either: scala.deriving.Mirror.Sum")) assert(!typeChecks("Either: scala.deriving.Mirror")) } + + def testScala2CaseClassUnderscoreMembers() = { + val some: Some[Int] = Some(1) + // FIXME: assert(!typeChecks("some._1")) + }