Skip to content

Commit b5f7cfb

Browse files
committed
Add Case flag to synthetic unapply methods with -Yscala2-stdlib
1 parent 78bee4e commit b5f7cfb

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,13 +805,15 @@ object desugar {
805805
else if caseClassInScala2StdLib then scala2LibCompatUnapplyRhs(unapplyParam.name)
806806
else Ident(unapplyParam.name)
807807
val unapplyResTp = if (arity == 0) Literal(Constant(true)) else TypeTree()
808-
808+
val unapplyMods =
809+
if ctx.settings.Yscala2Stdlib.value then synthetic | Case
810+
else synthetic
809811
DefDef(
810812
methName,
811813
joinParams(derivedTparams, (unapplyParam :: Nil) :: Nil),
812814
unapplyResTp,
813815
unapplyRHS
814-
).withMods(synthetic)
816+
).withMods(unapplyMods)
815817
}
816818
val toStringMeth =
817819
DefDef(nme.toString_, Nil, TypeTree(), Literal(Constant(className.toString))).withMods(Modifiers(Override | Synthetic))

compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,7 @@ object PatternMatcher {
330330
lazy val caseAccessors = caseClass.caseAccessors.filter(sym => sym.is(Method) || sym.owner.is(Scala2Tasty))
331331

332332
def isSyntheticScala2Unapply(sym: Symbol) =
333-
sym.is(Synthetic) && (
334-
(sym.is(Case) && sym.owner.is(Scala2x))
335-
|| sym.owner.is(Scala2Tasty)
336-
)
333+
sym.isAllOf(SyntheticCase) && sym.owner.is(Scala2x)
337334

338335
def tupleApp(i: Int, receiver: Tree) = // manually inlining the call to NonEmptyTuple#apply, because it's an inline method
339336
ref(defn.RuntimeTuplesModule)

0 commit comments

Comments
 (0)