@@ -4,9 +4,10 @@ package tasty
4
4
import scala .jdk .CollectionConverters ._
5
5
6
6
import scala .quoted ._
7
+ import scala .annotation .*
7
8
8
- import NameNormalizer ._
9
- import SyntheticsSupport ._
9
+ import NameNormalizer .*
10
+ import SyntheticsSupport .*
10
11
11
12
trait TypesSupport :
12
13
self : TastyParser =>
@@ -141,24 +142,24 @@ trait TypesSupport:
141
142
.reduceLeftOption((acc : SSignature , elem : SSignature ) => acc ++ plain(" , " ).l ++ elem).getOrElse(List ())
142
143
++ plain(" )" ).l
143
144
144
- 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
145
147
case m : MethodType => {
146
148
val paramList = getParamList(m)
147
149
keyword(" def " ).l ++ plain(name).l ++ polyTyped ++ paramList ++ plain(" : " ).l ++ inner(m.resType)
148
150
}
149
- case t : PolyType => {
151
+ case t : PolyType =>
150
152
val paramBounds = getParamBounds(t)
151
- val parsedMethod = parseRefinedElem(name, t.resType)
152
- if (! paramBounds.isEmpty){
153
+ if ! paramBounds.isEmpty then
153
154
parseRefinedElem(name, t.resType, plain(" [" ).l ++ paramBounds ++ plain(" ]" ).l)
154
- } else parseRefinedElem(name, t.resType)
155
- }
155
+ else parseRefinedElem(name, t.resType, polyTyped = Nil )
156
156
case ByNameType (tp) => keyword(" def " ).l ++ plain(s " $name: " ).l ++ inner(tp)
157
157
case t : TypeBounds => keyword(" type " ).l ++ plain(name).l ++ inner(t)
158
158
case t : TypeRef => keyword(" val " ).l ++ plain(s " $name: " ).l ++ inner(t)
159
159
case t : TermRef => keyword(" val " ).l ++ plain(s " $name: " ).l ++ inner(t)
160
160
case other => noSupported(s " Not supported type in refinement $info" )
161
- } ) ++ plain(" ; " ).l
161
+
162
+ ssig ++ plain(" ; " ).l
162
163
163
164
def parsePolyFunction (info : TypeRepr ): SSignature = info match {
164
165
case t : PolyType =>
@@ -225,6 +226,7 @@ trait TypesSupport:
225
226
}) ++ plain(" ]" ).l
226
227
227
228
case tp @ TypeRef (qual, typeName) =>
229
+ inline def wrapping = shouldWrapInParens(inner = qual, outer = tp, isLeft = true )
228
230
qual match {
229
231
case r : RecursiveThis => tpe(s " this. $typeName" ).l
230
232
case t if skipPrefix(t, elideThis) =>
@@ -245,17 +247,17 @@ trait TypesSupport:
245
247
case _ => tpe(tp.typeSymbol)
246
248
case Some (_) => tpe(tp.typeSymbol)
247
249
case None =>
248
- val sig = inParens(inner(qual)(using skipTypeSuffix = true ), shouldWrapInParens(qual, tp, true ))
250
+ val sig = inParens(inner(qual)(using indent = indent, skipTypeSuffix = true ), wrapping )
249
251
sig ++ plain(" ." ).l ++ tpe(tp.typeSymbol)
250
252
case _ =>
251
- val sig = inParens(inner(qual), shouldWrapInParens(qual, tp, true ) )
253
+ val sig = inParens(inner(qual, skipThisTypePrefix), wrapping )
252
254
sig ++ keyword(" #" ).l ++ tpe(tp.typeSymbol)
253
255
}
254
256
255
257
case tr @ TermRef (qual, typeName) =>
256
258
val prefix = qual match
257
259
case t if skipPrefix(t, elideThis) => Nil
258
- case tp => inner(tp)(using skipTypeSuffix = true ) ++ plain(" ." ).l
260
+ case tp => inner(tp)(using indent = indent, skipTypeSuffix = true ) ++ plain(" ." ).l
259
261
val suffix = if skipTypeSuffix then Nil else List (plain(" ." ), keyword(" type" ))
260
262
val typeSig = tr.termSymbol.tree match
261
263
case vd : ValDef if tr.termSymbol.flags.is(Flags .Module ) =>
@@ -274,9 +276,9 @@ trait TypesSupport:
274
276
val spaces = " " * (indent)
275
277
val casesTexts = cases.flatMap {
276
278
case MatchCase (from, to) =>
277
- 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
278
280
case TypeLambda (_, _, MatchCase (from, to)) =>
279
- 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
280
282
}
281
283
inner(sc) ++ keyword(" match " ).l ++ plain(" {\n " ).l ++ casesTexts ++ plain(spaces + " }" ).l
282
284
0 commit comments