@@ -695,19 +695,21 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
695
695
companion.findMember(nme.unapplySeq, NoPrefix , required = EmptyFlags , excluded = Synthetic ).exists
696
696
}
697
697
698
- def doShow (s : Space , mergeList : Boolean = false ): String = s match {
698
+ def doShow (s : Space , flattenList : Boolean = false ): String = s match {
699
699
case Empty => " "
700
700
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
702
704
case Typ (tp, decomposed) =>
703
705
val sym = tp.widen.classSymbol
704
706
705
707
if (ctx.definitions.isTupleType(tp))
706
708
params(tp).map(_ => " _" ).mkString(" (" , " , " , " )" )
707
709
else if (scalaListType.isRef(sym))
708
- if (mergeList ) " _: _*" else " _: List"
710
+ if (flattenList ) " _: _*" else " _: List"
709
711
else if (scalaConsType.isRef(sym))
710
- if (mergeList ) " _, _: _*" else " List(_, _: _*)"
712
+ if (flattenList ) " _, _: _*" else " List(_, _: _*)"
711
713
else if (tp.classSymbol.is(Sealed ) && tp.classSymbol.hasAnonymousChild)
712
714
" _: " + showType(tp) + " (anonymous)"
713
715
else if (tp.classSymbol.is(CaseClass ) && ! hasCustomUnapply(tp.classSymbol))
@@ -719,15 +721,18 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
719
721
if (ctx.definitions.isTupleType(tp))
720
722
" (" + params.map(doShow(_)).mkString(" , " ) + " )"
721
723
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
+ }
726
731
case Or (_) =>
727
732
throw new Exception (" incorrect flatten result " + s)
728
733
}
729
734
730
- flatten(s).map(doShow(_, false )).distinct.mkString(" , " )
735
+ flatten(s).map(doShow(_, flattenList = false )).distinct.mkString(" , " )
731
736
}
732
737
733
738
private def exhaustivityCheckable (sel : Tree ): Boolean = {
0 commit comments