@@ -451,30 +451,36 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
451451 /** Parameter types of the case class type `tp`. Adapted from `unapplyPlan` in patternMatcher */
452452 def signature (unapp : Type , unappSym : Symbol , argLen : Int ): List [Type ] = {
453453 def caseClass = unappSym.owner.linkedClass
454+
454455 lazy val caseAccessors = caseClass.caseAccessors.filter(_.is(Method ))
455456
456457 def isSyntheticScala2Unapply (sym : Symbol ) =
457458 sym.is(SyntheticCase ) && sym.owner.is(Scala2x )
458459
459- val mt @ MethodType (_) = unapp.widen
460+ val mt @ MethodType (_) = unapp.widen
460461
461- if (isSyntheticScala2Unapply(unappSym) && caseAccessors.length == argLen)
462- caseAccessors.map(_.info.asSeenFrom(mt.paramInfos.head, caseClass).widen)
463- else if (mt.resultType.isRef(defn.BooleanClass ))
464- List ()
465- else {
466- val isUnapplySeq = unappSym.name == nme.unapplySeq
467- if (isProductMatch(mt.resultType, argLen) && ! isUnapplySeq) {
468- productSelectors(mt.resultType).take(argLen)
469- .map(_.info.asSeenFrom(mt.resultType, mt.resultType.classSymbol).widen)
470- }
462+ val sig =
463+ if (isSyntheticScala2Unapply(unappSym) && caseAccessors.length == argLen)
464+ caseAccessors.map(_.info.asSeenFrom(mt.paramInfos.head, caseClass).widen)
465+ else if (mt.resultType.isRef(defn.BooleanClass ))
466+ List ()
471467 else {
472- val resTp = mt.resultType.select(nme.get).resultType.widen
473- if (isUnapplySeq) scalaListType.appliedTo(resTp.argTypes.head) :: Nil
474- else if (argLen == 0 ) Nil
475- else productSelectors(resTp).map(_.info.asSeenFrom(resTp, resTp.classSymbol).widen)
468+ val isUnapplySeq = unappSym.name == nme.unapplySeq
469+ if (isProductMatch(mt.resultType, argLen) && ! isUnapplySeq) {
470+ productSelectors(mt.resultType).take(argLen)
471+ .map(_.info.asSeenFrom(mt.resultType, mt.resultType.classSymbol).widen)
472+ }
473+ else {
474+ val resTp = mt.resultType.select(nme.get).resultType.widen
475+ if (isUnapplySeq) scalaListType.appliedTo(resTp.argTypes.head) :: Nil
476+ else if (argLen == 0 ) Nil
477+ else resTp :: Nil
478+ }
476479 }
477- }
480+
481+ debug.println(s " signature of ${unappSym.showFullName} ----> ${sig.map(_.show).mkString(" , " )}" )
482+
483+ sig
478484 }
479485
480486 /** Decompose a type into subspaces -- assume the type can be decomposed */
0 commit comments