@@ -2777,30 +2777,29 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
27772777
27782778 /** String representation of symbol's definition following its name */
27792779 final def infoString (tp : Type ): String = {
2780- def parents = (
2781- if (settings.debug.value) parentsString(tp.parents)
2782- else briefParentsString(tp.parents)
2783- )
2784- def isStructuralThisType = (
2785- // prevents disasters like scala/bug#8158
2786- owner.isInitialized && owner.isStructuralRefinement && tp == owner.tpe
2787- )
2788- if (isType) typeParamsString(tp) + (
2789- if (isClass) " extends " + parents
2790- else if (isAliasType) " = " + tp.resultType
2791- else tp.resultType match {
2792- case rt @ TypeBounds (_, _) => " " + rt
2793- case rt => " <: " + rt
2780+ def loop (tp : Type , followsParens : Boolean ): String = {
2781+ def isStructuralThisType = owner.isInitialized && owner.isStructuralRefinement && tp == owner.tpe // scala/bug#8158
2782+ // colon+space, preceded by an extra space if needed to prevent the colon glomming onto a symbolic name
2783+ def postnominalColon : String = if (! followsParens && name.isOperatorName) " : " else " : "
2784+ def parents = if (settings.debug) parentsString(tp.parents) else briefParentsString(tp.parents)
2785+ def typeRest =
2786+ if (isClass) " extends " + parents
2787+ else if (isAliasType) " = " + tp.resultType
2788+ else tp.resultType match {
2789+ case rt@ TypeBounds (_, _) => " " + rt
2790+ case rt => " <: " + rt
2791+ }
2792+ tp match {
2793+ case _ if isType => typeParamsString(tp) + typeRest
2794+ case _ if isModule => " " // avoid "object X of type X.type"
2795+ case PolyType (tparams, res) => typeParamsString(tp) + loop(res, followsParens = true )
2796+ case NullaryMethodType (res) => loop(res, followsParens = false )
2797+ case MethodType (params, res) => valueParamsString(tp) + loop(res, followsParens = true )
2798+ case _ if isStructuralThisType => postnominalColon + owner.name
2799+ case _ => postnominalColon + tp
27942800 }
2795- )
2796- else if (isModule) " " // avoid "object X of type X.type"
2797- else tp match {
2798- case PolyType (tparams, res) => typeParamsString(tp) + infoString(res)
2799- case NullaryMethodType (res) => infoString(res)
2800- case MethodType (params, res) => valueParamsString(tp) + infoString(res)
2801- case _ if isStructuralThisType => " : " + owner.name
2802- case _ => " : " + tp
28032801 }
2802+ loop(tp, followsParens = false )
28042803 }
28052804
28062805 def infosString = infos.toString
0 commit comments