@@ -81,7 +81,6 @@ trait TypesSupport:
8181      case  tpe =>  inner(tpe, skipThisTypePrefix)
8282
8383  //  TODO #23 add support for all types signatures that make sense
84-   @ nowarn(" id=E219" 
8584  private  def  inner (
8685    using Quotes ,
8786  )(
@@ -158,24 +157,25 @@ trait TypesSupport:
158157            .reduceLeftOption((acc : SSignature , elem : SSignature ) =>  acc ++  plain(" , " ++  elem).getOrElse(List ())
159158          ++  plain(" )" 
160159
161-         def  parseRefinedElem (name : String , info : TypeRepr , polyTyped : SSignature  =  Nil ):  SSignature  =  ( info match  {
160+         def  parseRefinedElem (name : String , info : TypeRepr , polyTyped : SSignature  =  Nil ):  SSignature  = 
161+           val  ssig  =  info match 
162162          case  m : MethodType  =>  {
163163            val  paramList  =  getParamList(m)
164164            keyword(" def " ++  plain(name).l ++  polyTyped ++  paramList ++  plain(" : " ++  inner(m.resType, skipThisTypePrefix)
165165          }
166-           case  t : PolyType  =>  { 
166+           case  t : PolyType  => 
167167            val  paramBounds  =  getParamBounds(t)
168-             val  parsedMethod  =  parseRefinedElem(name, t.resType)
169-             if  (! paramBounds.isEmpty){
168+             if  ! paramBounds.isEmpty then 
170169              parseRefinedElem(name, t.resType, plain(" [" ++  paramBounds ++  plain(" ]" 
171-             }  else  parseRefinedElem(name, t.resType) 
172-           } 
170+             else 
171+               parseRefinedElem(name, t.resType, polyTyped  =   Nil ) 
173172          case  ByNameType (tp) =>  keyword(" def " ++  plain(s " $name:  " ).l ++  inner(tp, skipThisTypePrefix)
174173          case  t : TypeBounds  =>  keyword(" type " ++  plain(name).l ++  inner(t, skipThisTypePrefix)
175174          case  t : TypeRef  =>  keyword(" val " ++  plain(s " $name:  " ).l ++  inner(t, skipThisTypePrefix)
176175          case  t : TermRef  =>  keyword(" val " ++  plain(s " $name:  " ).l ++  inner(t, skipThisTypePrefix)
177176          case  other =>  noSupported(s " Not supported type in refinement  $info" )
178-         } ) ++  plain(" ; " 
177+ 
178+           ssig ++  plain(" ; " 
179179
180180        def  parsePolyFunction (info : TypeRepr ):  SSignature  =  info match  {
181181          case  t : PolyType  => 
@@ -256,6 +256,7 @@ trait TypesSupport:
256256        }) ++  plain(" ]" 
257257
258258      case  tp @  TypeRef (qual, typeName) => 
259+         inline  def  wrapping  =  shouldWrapInParens(inner =  qual, outer =  tp, isLeft =  true )
259260        qual match  {
260261          case  r : RecursiveThis  =>  tpe(s " this. $typeName" ).l
261262          case  ThisType (tr) => 
@@ -272,23 +273,28 @@ trait TypesSupport:
272273              if  skipPrefix(qual, elideThis, originalOwner, skipThisTypePrefix) then 
273274                tpe(tp.typeSymbol)
274275              else 
275-                 val  sig  =  inParens(inner(qual, skipThisTypePrefix)(using  skipTypeSuffix =  true ), shouldWrapInParens(qual, tp, true ))
276-                 sig ++  plain(" ." ++  tpe(tp.typeSymbol)
276+                 val  sig  =  inParens(
277+                   inner(qual, skipThisTypePrefix)(using  indent =  indent, skipTypeSuffix =  true ), wrapping)
278+                    sig
279+                 ++  plain(" ." 
280+                 ++  tpe(tp.typeSymbol)
277281
278282          case  t if  skipPrefix(t, elideThis, originalOwner, skipThisTypePrefix) => 
279283            tpe(tp.typeSymbol)
280284          case  _ : TermRef  |  _ : ParamRef  => 
281285            val  suffix  =  if  tp.typeSymbol ==  Symbol .noSymbol then  tpe(typeName).l else  tpe(tp.typeSymbol)
282-             inner(qual, skipThisTypePrefix)(using  skipTypeSuffix =  true ) ++  plain(" ." ++  suffix
286+                inner(qual, skipThisTypePrefix)(using  indent =  indent, skipTypeSuffix =  true )
287+             ++  plain(" ." 
288+             ++  suffix
283289          case  _ => 
284-             val  sig  =  inParens(inner(qual, skipThisTypePrefix), shouldWrapInParens(qual, tp,  true ) )
290+             val  sig  =  inParens(inner(qual, skipThisTypePrefix), wrapping )
285291            sig ++  keyword(" #" ++  tpe(tp.typeSymbol)
286292        }
287293
288294      case  tr @  TermRef (qual, typeName) => 
289295        val  prefix  =  qual match 
290296          case  t if  skipPrefix(t, elideThis, originalOwner, skipThisTypePrefix) =>  Nil 
291-           case  tp =>  inner(tp, skipThisTypePrefix)(using  skipTypeSuffix =  true ) ++  plain(" ." 
297+           case  tp =>  inner(tp, skipThisTypePrefix)(using  indent  =  indent,  skipTypeSuffix =  true ) ++  plain(" ." 
292298        val  suffix  =  if  skipTypeSuffix then  Nil  else  List (plain(" ." " type" 
293299        val  typeSig  =  tr.termSymbol.tree match 
294300          case  vd : ValDef  if  tr.termSymbol.flags.is(Flags .Module ) => 
@@ -307,9 +313,17 @@ trait TypesSupport:
307313        val  spaces  =  "  " *  (indent)
308314        val  casesTexts  =  cases.flatMap {
309315          case  MatchCase (from, to) => 
310-             keyword(caseSpaces +  " case " ++  inner(from, skipThisTypePrefix) ++  keyword("  => " ++  inner(to, skipThisTypePrefix)(using  indent =  indent +  2 ) ++  plain(" \n " 
316+                keyword(caseSpaces +  " case " 
317+             ++  inner(from, skipThisTypePrefix)
318+             ++  keyword("  => " 
319+             ++  inner(to, skipThisTypePrefix)(using  indent =  indent +  2 , skipTypeSuffix =  skipTypeSuffix)
320+             ++  plain(" \n " 
311321          case  TypeLambda (_, _, MatchCase (from, to)) => 
312-             keyword(caseSpaces +  " case " ++  inner(from, skipThisTypePrefix) ++  keyword("  => " ++  inner(to, skipThisTypePrefix)(using  indent =  indent +  2 ) ++  plain(" \n " 
322+                keyword(caseSpaces +  " case " 
323+             ++  inner(from, skipThisTypePrefix)
324+             ++  keyword("  => " 
325+             ++  inner(to, skipThisTypePrefix)(using  indent =  indent +  2 , skipTypeSuffix =  skipTypeSuffix)
326+             ++  plain(" \n " 
313327        }
314328        inner(sc, skipThisTypePrefix) ++  keyword("  match " ++  plain(" {\n " ++  casesTexts ++  plain(spaces +  " }" 
315329
0 commit comments