@@ -92,11 +92,12 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
9292 override def toTextRef (tp : SingletonType ): Text = controlled {
9393 tp match {
9494 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)
9798 case _ =>
99+ super .toTextRef(tp)
98100 }
99- super .toTextRef(tp)
100101 }
101102
102103 override def toTextPrefix (tp : Type ): Text = controlled {
@@ -105,15 +106,15 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
105106 else if (homogenizedView) isEmptyPrefix(sym) // drop <root> and anonymous classes, but not scala, Predef.
106107 else isOmittablePrefix(sym)
107108 tp match {
108- case tp : ThisType =>
109- if (isOmittable(tp.cls)) return " "
109+ case tp : ThisType if isOmittable(tp.cls) =>
110+ " "
110111 case tp @ TermRef (pre, _) =>
111112 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)
115117 }
116- super .toTextPrefix(tp)
117118 }
118119
119120 override protected def toTextParents (parents : List [Type ]): Text =
@@ -180,69 +181,69 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
180181 homogenize(tp) match {
181182 case tp @ AppliedType (tycon, args) =>
182183 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)) {
187188 val l :: r :: Nil = args
188189 val opName = tyconName(tycon)
189-
190- return toTextInfixType(tyconName(tycon), l, r) { simpleNameString(tycon.typeSymbol) }
190+ toTextInfixType(tyconName(tycon), l, r) { simpleNameString(tycon.typeSymbol) }
191191 }
192+ else super .toText(tp)
192193
193194 // Since RefinedPrinter, unlike PlainPrinter, can output right-associative type-operators, we must override handling
194195 // of AndType and OrType to account for associativity
195196 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 ) }
197198 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 ) }
200200 case EtaExpansion (tycon) if ! printDebug =>
201- return toText(tycon)
201+ toText(tycon)
202202 case tp : RefinedType if defn.isFunctionType(tp) =>
203- return toTextDependentFunction(tp.refinedInfo.asInstanceOf [MethodType ])
203+ toTextDependentFunction(tp.refinedInfo.asInstanceOf [MethodType ])
204204 case tp : TypeRef =>
205205 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 ))
208208 tp.prefix match {
209209 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)
212212 }
213+ else super .toText(tp)
213214 case tp : ExprType =>
214- return exprToText(tp)
215+ exprToText(tp)
215216 case ErasedValueType (tycon, underlying) =>
216- return " ErasedValueType(" ~ toText(tycon) ~ " , " ~ toText(underlying) ~ " )"
217+ " ErasedValueType(" ~ toText(tycon) ~ " , " ~ toText(underlying) ~ " )"
217218 case tp : ClassInfo =>
218- return toTextParents(tp.parents) ~~ " {...}"
219+ toTextParents(tp.parents) ~~ " {...}"
219220 case JavaArrayType (elemtp) =>
220- return toText(elemtp) ~ " []"
221+ toText(elemtp) ~ " []"
221222 case tp : AnnotatedType if homogenizedView =>
222223 // Positions of annotations in types are not serialized
223224 // (they don't need to because we keep the original type tree with
224225 // the original annotation anyway. Therefore, there will always be
225226 // one version of the annotation tree that has the correct positions).
226- return withoutPos(super .toText(tp))
227+ withoutPos(super .toText(tp))
227228 case tp : SelectionProto =>
228- return " ?{ " ~ toText(tp.name) ~
229+ " ?{ " ~ toText(tp.name) ~
229230 (Str (" " ) provided ! tp.name.toSimpleName.last.isLetterOrDigit) ~
230231 " : " ~ toText(tp.memberProto) ~ " }"
231232 case tp : ViewProto =>
232- return toText(tp.argType) ~ " ?=>? " ~ toText(tp.resultType)
233+ toText(tp.argType) ~ " ?=>? " ~ toText(tp.resultType)
233234 case tp @ FunProto (args, resultType) =>
234235 val argsText = args match {
235236 case dummyTreeOfType(tp) :: Nil if ! (tp isRef defn.NullClass ) => " null: " ~ toText(tp)
236237 case _ => toTextGlobal(args, " , " )
237238 }
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) ~ " ]"
239240 case IgnoredProto (ignored) =>
240- return " ?" ~ ((" (ignored: " ~ toText(ignored) ~ " )" ) provided printDebug)
241+ " ?" ~ ((" (ignored: " ~ toText(ignored) ~ " )" ) provided printDebug)
241242 case tp @ PolyProto (targs, resType) =>
242- return " [applied to [" ~ toTextGlobal(targs, " , " ) ~ " ] returning " ~ toText(resType)
243+ " [applied to [" ~ toTextGlobal(targs, " , " ) ~ " ] returning " ~ toText(resType)
243244 case _ =>
245+ super .toText(tp)
244246 }
245- super .toText(tp)
246247 }
247248
248249 protected def exprToText (tp : ExprType ): Text =
0 commit comments