@@ -77,7 +77,6 @@ trait TypesSupport:
77
77
case tpe => inner(tpe)
78
78
79
79
// TODO #23 add support for all types signatures that make sense
80
- @ nowarn(" id=E219" )
81
80
private def inner (
82
81
using Quotes ,
83
82
)(
@@ -143,24 +142,24 @@ trait TypesSupport:
143
142
.reduceLeftOption((acc : SSignature , elem : SSignature ) => acc ++ plain(" , " ).l ++ elem).getOrElse(List ())
144
143
++ plain(" )" ).l
145
144
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
147
147
case m : MethodType => {
148
148
val paramList = getParamList(m)
149
149
keyword(" def " ).l ++ plain(name).l ++ polyTyped ++ paramList ++ plain(" : " ).l ++ inner(m.resType)
150
150
}
151
- case t : PolyType => {
151
+ case t : PolyType =>
152
152
val paramBounds = getParamBounds(t)
153
- val parsedMethod = parseRefinedElem(name, t.resType)
154
- if (! paramBounds.isEmpty){
153
+ if ! paramBounds.isEmpty then
155
154
parseRefinedElem(name, t.resType, plain(" [" ).l ++ paramBounds ++ plain(" ]" ).l)
156
- } else parseRefinedElem(name, t.resType)
157
- }
155
+ else parseRefinedElem(name, t.resType, polyTyped = Nil )
158
156
case ByNameType (tp) => keyword(" def " ).l ++ plain(s " $name: " ).l ++ inner(tp)
159
157
case t : TypeBounds => keyword(" type " ).l ++ plain(name).l ++ inner(t)
160
158
case t : TypeRef => keyword(" val " ).l ++ plain(s " $name: " ).l ++ inner(t)
161
159
case t : TermRef => keyword(" val " ).l ++ plain(s " $name: " ).l ++ inner(t)
162
160
case other => noSupported(s " Not supported type in refinement $info" )
163
- } ) ++ plain(" ; " ).l
161
+
162
+ ssig ++ plain(" ; " ).l
164
163
165
164
def parsePolyFunction (info : TypeRepr ): SSignature = info match {
166
165
case t : PolyType =>
@@ -227,6 +226,7 @@ trait TypesSupport:
227
226
}) ++ plain(" ]" ).l
228
227
229
228
case tp @ TypeRef (qual, typeName) =>
229
+ inline def wrapping = shouldWrapInParens(inner = qual, outer = tp, isLeft = true )
230
230
qual match {
231
231
case r : RecursiveThis => tpe(s " this. $typeName" ).l
232
232
case t if skipPrefix(t, elideThis) =>
@@ -247,17 +247,17 @@ trait TypesSupport:
247
247
case _ => tpe(tp.typeSymbol)
248
248
case Some (_) => tpe(tp.typeSymbol)
249
249
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 )
251
251
sig ++ plain(" ." ).l ++ tpe(tp.typeSymbol)
252
252
case _ =>
253
- val sig = inParens(inner(qual), shouldWrapInParens(qual, tp, true ) )
253
+ val sig = inParens(inner(qual, skipThisTypePrefix), wrapping )
254
254
sig ++ keyword(" #" ).l ++ tpe(tp.typeSymbol)
255
255
}
256
256
257
257
case tr @ TermRef (qual, typeName) =>
258
258
val prefix = qual match
259
259
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
261
261
val suffix = if skipTypeSuffix then Nil else List (plain(" ." ), keyword(" type" ))
262
262
val typeSig = tr.termSymbol.tree match
263
263
case vd : ValDef if tr.termSymbol.flags.is(Flags .Module ) =>
@@ -276,9 +276,9 @@ trait TypesSupport:
276
276
val spaces = " " * (indent)
277
277
val casesTexts = cases.flatMap {
278
278
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
280
280
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
282
282
}
283
283
inner(sc) ++ keyword(" match " ).l ++ plain(" {\n " ).l ++ casesTexts ++ plain(spaces + " }" ).l
284
284
0 commit comments