@@ -695,19 +695,21 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
695695 companion.findMember(nme.unapplySeq, NoPrefix , required = EmptyFlags , excluded = Synthetic ).exists
696696 }
697697
698- def doShow (s : Space , mergeList : Boolean = false ): String = s match {
698+ def doShow (s : Space , flattenList : Boolean = false ): String = s match {
699699 case Empty => " "
700700 case Typ (c : ConstantType , _) => " " + c.value.value
701- case Typ (tp : TermRef , _) => tp.symbol.showName
701+ case Typ (tp : TermRef , _) =>
702+ if (flattenList && tp <:< scalaNilType) " "
703+ else tp.symbol.showName
702704 case Typ (tp, decomposed) =>
703705 val sym = tp.widen.classSymbol
704706
705707 if (ctx.definitions.isTupleType(tp))
706708 params(tp).map(_ => " _" ).mkString(" (" , " , " , " )" )
707709 else if (scalaListType.isRef(sym))
708- if (mergeList ) " _: _*" else " _: List"
710+ if (flattenList ) " _: _*" else " _: List"
709711 else if (scalaConsType.isRef(sym))
710- if (mergeList ) " _, _: _*" else " List(_, _: _*)"
712+ if (flattenList ) " _, _: _*" else " List(_, _: _*)"
711713 else if (tp.classSymbol.is(Sealed ) && tp.classSymbol.hasAnonymousChild)
712714 " _: " + showType(tp) + " (anonymous)"
713715 else if (tp.classSymbol.is(CaseClass ) && ! hasCustomUnapply(tp.classSymbol))
@@ -719,15 +721,18 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
719721 if (ctx.definitions.isTupleType(tp))
720722 " (" + params.map(doShow(_)).mkString(" , " ) + " )"
721723 else if (tp.isRef(scalaConsType.symbol))
722- if (mergeList) params.map(doShow(_, mergeList)).mkString(" , " )
723- else params.map(doShow(_, true )).filter(_ != " Nil" ).mkString(" List(" , " , " , " )" )
724- else
725- showType(sym.owner.typeRef) + params.map(doShow(_)).mkString(" (" , " , " , " )" )
724+ if (flattenList) params.map(doShow(_, flattenList)).mkString(" , " )
725+ else params.map(doShow(_, flattenList = true )).filter(! _.isEmpty).mkString(" List(" , " , " , " )" )
726+ else {
727+ val isUnapplySeq = sym.name.eq(nme.unapplySeq)
728+ val paramsStr = params.map(doShow(_, flattenList = isUnapplySeq)).mkString(" (" , " , " , " )" )
729+ showType(sym.owner.typeRef) + paramsStr
730+ }
726731 case Or (_) =>
727732 throw new Exception (" incorrect flatten result " + s)
728733 }
729734
730- flatten(s).map(doShow(_, false )).distinct.mkString(" , " )
735+ flatten(s).map(doShow(_, flattenList = false )).distinct.mkString(" , " )
731736 }
732737
733738 private def exhaustivityCheckable (sel : Tree ): Boolean = {
0 commit comments