@@ -77,7 +77,6 @@ trait TypesSupport:
7777 case tpe => inner(tpe)
7878
7979 // TODO #23 add support for all types signatures that make sense
80- @ nowarn(" id=E219" )
8180 private def inner (
8281 using Quotes ,
8382 )(
@@ -143,24 +142,24 @@ trait TypesSupport:
143142 .reduceLeftOption((acc : SSignature , elem : SSignature ) => acc ++ plain(" , " ).l ++ elem).getOrElse(List ())
144143 ++ plain(" )" ).l
145144
146- def parseRefinedElem (name : String , info : TypeRepr , polyTyped : SSignature = Nil ): SSignature = ( info match {
145+ def parseRefinedElem (name : String , info : TypeRepr , polyTyped : SSignature = Nil ): SSignature =
146+ val ssig = info match
147147 case m : MethodType => {
148148 val paramList = getParamList(m)
149149 keyword(" def " ).l ++ plain(name).l ++ polyTyped ++ paramList ++ plain(" : " ).l ++ inner(m.resType)
150150 }
151- case t : PolyType => {
151+ case t : PolyType =>
152152 val paramBounds = getParamBounds(t)
153- val parsedMethod = parseRefinedElem(name, t.resType)
154- if (! paramBounds.isEmpty){
153+ if ! paramBounds.isEmpty then
155154 parseRefinedElem(name, t.resType, plain(" [" ).l ++ paramBounds ++ plain(" ]" ).l)
156- } else parseRefinedElem(name, t.resType)
157- }
155+ else parseRefinedElem(name, t.resType, polyTyped = Nil )
158156 case ByNameType (tp) => keyword(" def " ).l ++ plain(s " $name: " ).l ++ inner(tp)
159157 case t : TypeBounds => keyword(" type " ).l ++ plain(name).l ++ inner(t)
160158 case t : TypeRef => keyword(" val " ).l ++ plain(s " $name: " ).l ++ inner(t)
161159 case t : TermRef => keyword(" val " ).l ++ plain(s " $name: " ).l ++ inner(t)
162160 case other => noSupported(s " Not supported type in refinement $info" )
163- } ) ++ plain(" ; " ).l
161+
162+ ssig ++ plain(" ; " ).l
164163
165164 def parsePolyFunction (info : TypeRepr ): SSignature = info match {
166165 case t : PolyType =>
@@ -227,6 +226,7 @@ trait TypesSupport:
227226 }) ++ plain(" ]" ).l
228227
229228 case tp @ TypeRef (qual, typeName) =>
229+ inline def wrapping = shouldWrapInParens(inner = qual, outer = tp, isLeft = true )
230230 qual match {
231231 case r : RecursiveThis => tpe(s " this. $typeName" ).l
232232 case t if skipPrefix(t, elideThis) =>
@@ -247,17 +247,17 @@ trait TypesSupport:
247247 case _ => tpe(tp.typeSymbol)
248248 case Some (_) => tpe(tp.typeSymbol)
249249 case None =>
250- val sig = inParens(inner(qual)(using skipTypeSuffix = true ), shouldWrapInParens(qual, tp, true ))
250+ val sig = inParens(inner(qual)(using indent = indent, skipTypeSuffix = true ), wrapping )
251251 sig ++ plain(" ." ).l ++ tpe(tp.typeSymbol)
252252 case _ =>
253- val sig = inParens(inner(qual), shouldWrapInParens(qual, tp, true ) )
253+ val sig = inParens(inner(qual, skipThisTypePrefix), wrapping )
254254 sig ++ keyword(" #" ).l ++ tpe(tp.typeSymbol)
255255 }
256256
257257 case tr @ TermRef (qual, typeName) =>
258258 val prefix = qual match
259259 case t if skipPrefix(t, elideThis) => Nil
260- case tp => inner(tp)(using skipTypeSuffix = true ) ++ plain(" ." ).l
260+ case tp => inner(tp)(using indent = indent, skipTypeSuffix = true ) ++ plain(" ." ).l
261261 val suffix = if skipTypeSuffix then Nil else List (plain(" ." ), keyword(" type" ))
262262 val typeSig = tr.termSymbol.tree match
263263 case vd : ValDef if tr.termSymbol.flags.is(Flags .Module ) =>
@@ -276,9 +276,9 @@ trait TypesSupport:
276276 val spaces = " " * (indent)
277277 val casesTexts = cases.flatMap {
278278 case MatchCase (from, to) =>
279- keyword(caseSpaces + " case " ).l ++ inner(from) ++ keyword(" => " ).l ++ inner(to)(using indent = indent + 2 ) ++ plain(" \n " ).l
279+ keyword(caseSpaces + " case " ).l ++ inner(from) ++ keyword(" => " ).l ++ inner(to)(using indent = indent + 2 , skipTypeSuffix = skipTypeSuffix ) ++ plain(" \n " ).l
280280 case TypeLambda (_, _, MatchCase (from, to)) =>
281- keyword(caseSpaces + " case " ).l ++ inner(from) ++ keyword(" => " ).l ++ inner(to)(using indent = indent + 2 ) ++ plain(" \n " ).l
281+ keyword(caseSpaces + " case " ).l ++ inner(from) ++ keyword(" => " ).l ++ inner(to)(using indent = indent + 2 , skipTypeSuffix = skipTypeSuffix ) ++ plain(" \n " ).l
282282 }
283283 inner(sc) ++ keyword(" match " ).l ++ plain(" {\n " ).l ++ casesTexts ++ plain(spaces + " }" ).l
284284
0 commit comments