Skip to content

Commit b8be20f

Browse files
committed
Remove duplication in widenInferred
1 parent c758acb commit b8be20f

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,11 @@ trait ConstraintHandling[AbstractContext] {
283283
* as those could leak the annotation to users (see run/inferred-repeated-result).
284284
*/
285285
def widenInferred(inst: Type, bound: Type)(implicit actx: AbstractContext): Type = {
286-
def widenSingle(tp: Type) = {
287-
val tpw = tp.widenSingletons
286+
def tryWiden(tp: Type, widen: Type => Type) = {
287+
val tpw = widen(tp)
288288
if ((tpw ne tp) && tpw <:< bound) tpw else tp
289289
}
290-
def widenOr(tp: Type) = {
291-
val tpw = tp.widenUnion
292-
if ((tpw ne tp) && tpw <:< bound) tpw else tp
293-
}
294-
widenOr(widenSingle(inst)).dropRepeatedAnnot
290+
tryWiden(tryWiden(inst, _.widenSingletons), _.widenUnion).dropRepeatedAnnot
295291
}
296292

297293
/** The instance type of `param` in the current constraint (which contains `param`).

0 commit comments

Comments
 (0)