@@ -92,11 +92,12 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
92
92
override def toTextRef (tp : SingletonType ): Text = controlled {
93
93
tp match {
94
94
case tp : ThisType if ! printDebug =>
95
- if (tp.cls.isAnonymousClass) return keywordStr(" this" )
96
- if (tp.cls.is(ModuleClass )) return fullNameString(tp.cls.sourceModule)
95
+ if (tp.cls.isAnonymousClass) keywordStr(" this" )
96
+ if (tp.cls.is(ModuleClass )) fullNameString(tp.cls.sourceModule)
97
+ else super .toTextRef(tp)
97
98
case _ =>
99
+ super .toTextRef(tp)
98
100
}
99
- super .toTextRef(tp)
100
101
}
101
102
102
103
override def toTextPrefix (tp : Type ): Text = controlled {
@@ -105,15 +106,15 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
105
106
else if (homogenizedView) isEmptyPrefix(sym) // drop <root> and anonymous classes, but not scala, Predef.
106
107
else isOmittablePrefix(sym)
107
108
tp match {
108
- case tp : ThisType =>
109
- if (isOmittable(tp.cls)) return " "
109
+ case tp : ThisType if isOmittable(tp.cls) =>
110
+ " "
110
111
case tp @ TermRef (pre, _) =>
111
112
val sym = tp.symbol
112
- if (sym.isPackageObject && ! homogenizedView) return toTextPrefix(pre)
113
- if (isOmittable(sym)) return " "
114
- case _ =>
113
+ if (sym.isPackageObject && ! homogenizedView) toTextPrefix(pre)
114
+ else if (isOmittable(sym)) " "
115
+ else super .toTextPrefix(tp)
116
+ case _ => super .toTextPrefix(tp)
115
117
}
116
- super .toTextPrefix(tp)
117
118
}
118
119
119
120
override protected def toTextParents (parents : List [Type ]): Text =
@@ -180,69 +181,69 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
180
181
homogenize(tp) match {
181
182
case tp @ AppliedType (tycon, args) =>
182
183
val cls = tycon.typeSymbol
183
- if (tycon.isRepeatedParam) return toTextLocal(args.head) ~ " *"
184
- if (defn.isFunctionClass(cls)) return toTextFunction(args, cls.name.isImplicitFunction, cls.name.isErasedFunction)
185
- if (tp.tupleArity >= 2 && ! printDebug) return toTextTuple(tp.tupleElementTypes)
186
- if (isInfixType(tp)) {
184
+ if (tycon.isRepeatedParam) toTextLocal(args.head) ~ " *"
185
+ else if (defn.isFunctionClass(cls)) toTextFunction(args, cls.name.isImplicitFunction, cls.name.isErasedFunction)
186
+ else if (tp.tupleArity >= 2 && ! printDebug) toTextTuple(tp.tupleElementTypes)
187
+ else if (isInfixType(tp)) {
187
188
val l :: r :: Nil = args
188
189
val opName = tyconName(tycon)
189
-
190
- return toTextInfixType(tyconName(tycon), l, r) { simpleNameString(tycon.typeSymbol) }
190
+ toTextInfixType(tyconName(tycon), l, r) { simpleNameString(tycon.typeSymbol) }
191
191
}
192
+ else super .toText(tp)
192
193
193
194
// Since RefinedPrinter, unlike PlainPrinter, can output right-associative type-operators, we must override handling
194
195
// of AndType and OrType to account for associativity
195
196
case AndType (tp1, tp2) =>
196
- return toTextInfixType(tpnme.raw.AMP , tp1, tp2) { toText(tpnme.raw.AMP ) }
197
+ toTextInfixType(tpnme.raw.AMP , tp1, tp2) { toText(tpnme.raw.AMP ) }
197
198
case OrType (tp1, tp2) =>
198
- return toTextInfixType(tpnme.raw.BAR , tp1, tp2) { toText(tpnme.raw.BAR ) }
199
-
199
+ toTextInfixType(tpnme.raw.BAR , tp1, tp2) { toText(tpnme.raw.BAR ) }
200
200
case EtaExpansion (tycon) if ! printDebug =>
201
- return toText(tycon)
201
+ toText(tycon)
202
202
case tp : RefinedType if defn.isFunctionType(tp) =>
203
- return toTextDependentFunction(tp.refinedInfo.asInstanceOf [MethodType ])
203
+ toTextDependentFunction(tp.refinedInfo.asInstanceOf [MethodType ])
204
204
case tp : TypeRef =>
205
205
if (tp.symbol.isAnonymousClass && ! ctx.settings.uniqid.value)
206
- return toText(tp.info)
207
- if (tp.symbol.is(Param ))
206
+ toText(tp.info)
207
+ else if (tp.symbol.is(Param ))
208
208
tp.prefix match {
209
209
case pre : ThisType if pre.cls == tp.symbol.owner =>
210
- return nameString(tp.symbol)
211
- case _ =>
210
+ nameString(tp.symbol)
211
+ case _ => super .toText(tp)
212
212
}
213
+ else super .toText(tp)
213
214
case tp : ExprType =>
214
- return exprToText(tp)
215
+ exprToText(tp)
215
216
case ErasedValueType (tycon, underlying) =>
216
- return " ErasedValueType(" ~ toText(tycon) ~ " , " ~ toText(underlying) ~ " )"
217
+ " ErasedValueType(" ~ toText(tycon) ~ " , " ~ toText(underlying) ~ " )"
217
218
case tp : ClassInfo =>
218
- return toTextParents(tp.parents) ~~ " {...}"
219
+ toTextParents(tp.parents) ~~ " {...}"
219
220
case JavaArrayType (elemtp) =>
220
- return toText(elemtp) ~ " []"
221
+ toText(elemtp) ~ " []"
221
222
case tp : AnnotatedType if homogenizedView =>
222
223
// Positions of annotations in types are not serialized
223
224
// (they don't need to because we keep the original type tree with
224
225
// the original annotation anyway. Therefore, there will always be
225
226
// one version of the annotation tree that has the correct positions).
226
- return withoutPos(super .toText(tp))
227
+ withoutPos(super .toText(tp))
227
228
case tp : SelectionProto =>
228
- return " ?{ " ~ toText(tp.name) ~
229
+ " ?{ " ~ toText(tp.name) ~
229
230
(Str (" " ) provided ! tp.name.toSimpleName.last.isLetterOrDigit) ~
230
231
" : " ~ toText(tp.memberProto) ~ " }"
231
232
case tp : ViewProto =>
232
- return toText(tp.argType) ~ " ?=>? " ~ toText(tp.resultType)
233
+ toText(tp.argType) ~ " ?=>? " ~ toText(tp.resultType)
233
234
case tp @ FunProto (args, resultType) =>
234
235
val argsText = args match {
235
236
case dummyTreeOfType(tp) :: Nil if ! (tp isRef defn.NullClass ) => " null: " ~ toText(tp)
236
237
case _ => toTextGlobal(args, " , " )
237
238
}
238
- return " [applied to " ~ (Str (" given " ) provided tp.isContextualMethod) ~ (Str (" erased " ) provided tp.isErasedMethod) ~ " (" ~ argsText ~ " ) returning " ~ toText(resultType) ~ " ]"
239
+ " [applied to " ~ (Str (" given " ) provided tp.isContextualMethod) ~ (Str (" erased " ) provided tp.isErasedMethod) ~ " (" ~ argsText ~ " ) returning " ~ toText(resultType) ~ " ]"
239
240
case IgnoredProto (ignored) =>
240
- return " ?" ~ ((" (ignored: " ~ toText(ignored) ~ " )" ) provided printDebug)
241
+ " ?" ~ ((" (ignored: " ~ toText(ignored) ~ " )" ) provided printDebug)
241
242
case tp @ PolyProto (targs, resType) =>
242
- return " [applied to [" ~ toTextGlobal(targs, " , " ) ~ " ] returning " ~ toText(resType)
243
+ " [applied to [" ~ toTextGlobal(targs, " , " ) ~ " ] returning " ~ toText(resType)
243
244
case _ =>
245
+ super .toText(tp)
244
246
}
245
- super .toText(tp)
246
247
}
247
248
248
249
protected def exprToText (tp : ExprType ): Text =
0 commit comments