Skip to content

Commit 22cdeec

Browse files
committed
Simplify signature: remove special case for Scala 2 case class
1 parent 9627957 commit 22cdeec

File tree

1 file changed

+2
-10
lines changed
  • compiler/src/dotty/tools/dotc/transform/patmat

1 file changed

+2
-10
lines changed

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -527,15 +527,9 @@ class SpaceEngine(using Context) extends SpaceLogic {
527527
/** Parameter types of the case class type `tp`. Adapted from `unapplyPlan` in patternMatcher */
528528
def signature(unapp: TermRef, scrutineeTp: Type, argLen: Int): List[Type] = {
529529
val unappSym = unapp.symbol
530-
def caseClass = unappSym.owner.linkedClass
531530

532531
// println("scrutineeTp = " + scrutineeTp.show)
533532

534-
lazy val caseAccessors = caseClass.caseAccessors.filter(_.is(Method))
535-
536-
def isSyntheticScala2Unapply(sym: Symbol) =
537-
sym.isAllOf(SyntheticCase) && sym.owner.is(Scala2x)
538-
539533
val mt: MethodType = unapp.widen match {
540534
case mt: MethodType => mt
541535
case pt: PolyType =>
@@ -564,9 +558,7 @@ class SpaceEngine(using Context) extends SpaceLogic {
564558
val resTp = mt.finalResultType
565559

566560
val sig =
567-
if (isSyntheticScala2Unapply(unappSym) && caseAccessors.length == argLen)
568-
caseAccessors.map(_.info.asSeenFrom(mt.paramInfos.head, caseClass).widenExpr)
569-
else if (resTp.isRef(defn.BooleanClass))
561+
if (resTp.isRef(defn.BooleanClass))
570562
List()
571563
else {
572564
val isUnapplySeq = unappSym.name == nme.unapplySeq
@@ -584,7 +576,7 @@ class SpaceEngine(using Context) extends SpaceLogic {
584576
if (arity > 0)
585577
productSelectorTypes(resTp, unappSym.srcPos)
586578
else {
587-
val getTp = resTp.select(nme.get).finalResultType.widen
579+
val getTp = resTp.select(nme.get).finalResultType.widenTermRefExpr
588580
if (argLen == 1) getTp :: Nil
589581
else productSelectorTypes(getTp, unappSym.srcPos)
590582
}

0 commit comments

Comments
 (0)