Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
liufengyun committed Apr 8, 2020
1 parent ccd2a45 commit 476638a
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions compiler/src/dotty/tools/dotc/transform/patmat/Space.scala
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,10 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
inContext(ctx.fresh.setNewTyperState()) {
val tvars = pt.paramInfos.map(newTypeVar)
val mt = pt.instantiate(tvars).asInstanceOf[MethodType]
// println("mt.paramInfos(0) = " + mt.paramInfos(0))
scrutineeTp <:< mt.paramInfos(0)
instantiateSelected(mt, tvars)
// isFullyDefined(mt, ForceDegree.flipBottom)
// println("mt = " + mt.show)
isFullyDefined(mt, ForceDegree.flipBottom)
// println("mt = " + mt)
mt
}
}
Expand All @@ -539,32 +539,32 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
// Case unapplySeq:
// 1. return the type `List[T]` where `T` is the element type of the unapplySeq return type `Seq[T]`

val resTp = mt.finalResultType

val sig =
if (isSyntheticScala2Unapply(unappSym) && caseAccessors.length == argLen)
caseAccessors.map(_.info.asSeenFrom(mt.paramInfos.head, caseClass).widenExpr)
else if (mt.finalResultType.isRef(defn.BooleanClass))
else if (resTp.isRef(defn.BooleanClass))
List()
else {
val isUnapplySeq = unappSym.name == nme.unapplySeq

if (isUnapplySeq) {
val (arity, elemTp, resultTp) = unapplySeqInfo(mt.finalResultType, unappSym.sourcePos)
val (arity, elemTp, resultTp) = unapplySeqInfo(resTp, unappSym.sourcePos)
if (elemTp.exists) scalaListType.appliedTo(elemTp) :: Nil
else {
val sels = productSeqSelectors(resultTp, arity, unappSym.sourcePos)
sels.init :+ scalaListType.appliedTo(sels.last)
}
}
else {
val arity = productArity(mt.finalResultType, unappSym.sourcePos)
val arity = productArity(resTp, unappSym.sourcePos)
if (arity > 0)
productSelectors(mt.finalResultType)
.map(_.info.asSeenFrom(mt.finalResultType, mt.resultType.classSymbol).widenExpr)
productSelectorTypes(resTp, unappSym.sourcePos)
else {
val resTp = mt.finalResultType.select(nme.get).finalResultType.widen
val arity = productArity(resTp, unappSym.sourcePos)
if (argLen == 1) resTp :: Nil
else productSelectors(resTp).map(_.info.asSeenFrom(resTp, resTp.classSymbol).widenExpr)
val getTp = resTp.select(nme.get).finalResultType.widen
if (argLen == 1) getTp :: Nil
else productSelectorTypes(getTp, unappSym.sourcePos)
}
}
}
Expand Down

0 comments on commit 476638a

Please sign in to comment.