@@ -293,10 +293,10 @@ trait ConstraintHandling[AbstractContext] {
293
293
294
294
/** Widen inferred type `inst` with upper `bound`, according to the following rules:
295
295
* 1. If `inst` is a singleton type, or a union containing some singleton types,
296
- * widen (all) the singleton type(s), provied the result is a subtype of `bound`
296
+ * widen (all) the singleton type(s), provided the result is a subtype of `bound`
297
297
* (i.e. `inst.widenSingletons <:< bound` succeeds with satisfiable constraint)
298
298
* 2. If `inst` is a union type, approximate the union type from above by an intersection
299
- * of all common base types, provied the result is a subtype of `bound`.
299
+ * of all common base types, provided the result is a subtype of `bound`.
300
300
*
301
301
* Don't do these widenings if `bound` is a subtype of `scala.Singleton`.
302
302
* Also, if the result of these widenings is a TypeRef to a module class,
@@ -309,15 +309,17 @@ trait ConstraintHandling[AbstractContext] {
309
309
def widenInferred (inst : Type , bound : Type )(implicit actx : AbstractContext ): Type = {
310
310
def widenOr (tp : Type ) = {
311
311
val tpw = tp.widenUnion
312
- if (( tpw ne tp) && tpw <:< bound) tpw else tp
312
+ if (tpw ne tp) && ( tpw <:< bound) then tpw else tp
313
313
}
314
314
def widenSingle (tp : Type ) = {
315
315
val tpw = tp.widenSingletons
316
- if (( tpw ne tp) && tpw <:< bound) tpw else tp
316
+ if (tpw ne tp) && ( tpw <:< bound) then tpw else tp
317
317
}
318
+ def isSingleton (tp : Type ): Boolean = tp match
319
+ case WildcardType (optBounds) => optBounds.exists && isSingleton(optBounds.bounds.hi)
320
+ case _ => isSubTypeWhenFrozen(tp, defn.SingletonType )
318
321
val wideInst =
319
- if (isSubTypeWhenFrozen(bound, defn.SingletonType )) inst
320
- else widenOr(widenSingle(inst))
322
+ if isSingleton(bound) then inst else widenOr(widenSingle(inst))
321
323
wideInst match
322
324
case wideInst : TypeRef if wideInst.symbol.is(Module ) =>
323
325
TermRef (wideInst.prefix, wideInst.symbol.sourceModule)
0 commit comments