Skip to content

Commit 6a9c4ea

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

File tree

1 file changed

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

1 file changed

+2
-7
lines changed

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -527,12 +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-
536533
def isSyntheticScala2Unapply(sym: Symbol) =
537534
sym.isAllOf(SyntheticCase) && sym.owner.is(Scala2x)
538535

@@ -564,9 +561,7 @@ class SpaceEngine(using Context) extends SpaceLogic {
564561
val resTp = mt.finalResultType
565562

566563
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))
564+
if (resTp.isRef(defn.BooleanClass))
570565
List()
571566
else {
572567
val isUnapplySeq = unappSym.name == nme.unapplySeq
@@ -584,7 +579,7 @@ class SpaceEngine(using Context) extends SpaceLogic {
584579
if (arity > 0)
585580
productSelectorTypes(resTp, unappSym.srcPos)
586581
else {
587-
val getTp = resTp.select(nme.get).finalResultType.widen
582+
val getTp = resTp.select(nme.get).finalResultType.widenTermRefExpr
588583
if (argLen == 1) getTp :: Nil
589584
else productSelectorTypes(getTp, unappSym.srcPos)
590585
}

0 commit comments

Comments
 (0)