Skip to content

Commit 4dfb838

Browse files
committed
Code refactoring
1 parent 18564c8 commit 4dfb838

File tree

1 file changed

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

1 file changed

+12
-12
lines changed

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,10 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
521521
inContext(ctx.fresh.setNewTyperState()) {
522522
val tvars = pt.paramInfos.map(newTypeVar)
523523
val mt = pt.instantiate(tvars).asInstanceOf[MethodType]
524+
// println("mt.paramInfos(0) = " + mt.paramInfos(0))
524525
scrutineeTp <:< mt.paramInfos(0)
525-
instantiateSelected(mt, tvars)
526-
// isFullyDefined(mt, ForceDegree.flipBottom)
527-
// println("mt = " + mt.show)
526+
isFullyDefined(mt, ForceDegree.flipBottom)
527+
// println("mt = " + mt)
528528
mt
529529
}
530530
}
@@ -539,32 +539,32 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
539539
// Case unapplySeq:
540540
// 1. return the type `List[T]` where `T` is the element type of the unapplySeq return type `Seq[T]`
541541

542+
val resTp = mt.finalResultType
543+
542544
val sig =
543545
if (isSyntheticScala2Unapply(unappSym) && caseAccessors.length == argLen)
544546
caseAccessors.map(_.info.asSeenFrom(mt.paramInfos.head, caseClass).widenExpr)
545-
else if (mt.finalResultType.isRef(defn.BooleanClass))
547+
else if (resTp.isRef(defn.BooleanClass))
546548
List()
547549
else {
548550
val isUnapplySeq = unappSym.name == nme.unapplySeq
549551

550552
if (isUnapplySeq) {
551-
val (arity, elemTp, resultTp) = unapplySeqInfo(mt.finalResultType, unappSym.sourcePos)
553+
val (arity, elemTp, resultTp) = unapplySeqInfo(resTp, unappSym.sourcePos)
552554
if (elemTp.exists) scalaListType.appliedTo(elemTp) :: Nil
553555
else {
554556
val sels = productSeqSelectors(resultTp, arity, unappSym.sourcePos)
555557
sels.init :+ scalaListType.appliedTo(sels.last)
556558
}
557559
}
558560
else {
559-
val arity = productArity(mt.finalResultType, unappSym.sourcePos)
561+
val arity = productArity(resTp, unappSym.sourcePos)
560562
if (arity > 0)
561-
productSelectors(mt.finalResultType)
562-
.map(_.info.asSeenFrom(mt.finalResultType, mt.resultType.classSymbol).widenExpr)
563+
productSelectorTypes(resTp, unappSym.sourcePos)
563564
else {
564-
val resTp = mt.finalResultType.select(nme.get).finalResultType.widen
565-
val arity = productArity(resTp, unappSym.sourcePos)
566-
if (argLen == 1) resTp :: Nil
567-
else productSelectors(resTp).map(_.info.asSeenFrom(resTp, resTp.classSymbol).widenExpr)
565+
val getTp = resTp.select(nme.get).finalResultType.widen
566+
if (argLen == 1) getTp :: Nil
567+
else productSelectorTypes(getTp, unappSym.sourcePos)
568568
}
569569
}
570570
}

0 commit comments

Comments
 (0)