File tree 2 files changed +28
-3
lines changed
src/dotty/tools/dotc/core
2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -269,9 +269,28 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
269
269
if (ctx.featureEnabled(defn.LanguageModuleClass , nme.keepUnions)) tp
270
270
else tp match {
271
271
case tp : OrType =>
272
- val commonBaseClasses = tp.mapReduceOr(_.baseClasses)(intersect)
273
- val doms = dominators(commonBaseClasses, Nil )
274
- doms.map(tp.baseTypeWithArgs).reduceLeft(AndType .apply)
272
+ def isClassRef (tp : Type ): Boolean = tp match {
273
+ case tp : TypeRef => tp.symbol.isClass
274
+ case tp : RefinedType => isClassRef(tp.parent)
275
+ case _ => false
276
+ }
277
+ def next (tp : TypeProxy ) = tp.underlying match {
278
+ case TypeBounds (_, hi) => hi
279
+ case nx => nx
280
+ }
281
+ tp.tp1 match {
282
+ case tp1 : TypeProxy if ! isClassRef(tp1) =>
283
+ approximateUnion(next(tp1) | tp.tp2)
284
+ case _ =>
285
+ tp.tp2 match {
286
+ case tp2 : TypeProxy if ! isClassRef(tp2) =>
287
+ approximateUnion(tp.tp1 | next(tp2))
288
+ case _ =>
289
+ val commonBaseClasses = tp.mapReduceOr(_.baseClasses)(intersect)
290
+ val doms = dominators(commonBaseClasses, Nil )
291
+ doms.map(tp.baseTypeWithArgs).reduceLeft(AndType .apply)
292
+ }
293
+ }
275
294
case tp @ AndType (tp1, tp2) =>
276
295
tp derived_& (approximateUnion(tp1), approximateUnion(tp2))
277
296
case tp : RefinedType =>
Original file line number Diff line number Diff line change
1
+ object Test {
2
+ def foo [A <: X , B <: X , X ](left : A , right : B ): Unit = {
3
+ val elem = if (false ) left else right
4
+ val check : X = elem
5
+ }
6
+ }
You can’t perform that action at this time.
0 commit comments