File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed
src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -269,9 +269,27 @@ 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 ) = tp match {
273
+ case tp : TypeRef => tp.symbol.isClass
274
+ case _ => false
275
+ }
276
+ def next (tp : TypeProxy ) = tp.underlying match {
277
+ case TypeBounds (_, hi) => hi
278
+ case nx => nx
279
+ }
280
+ tp.tp1 match {
281
+ case tp1 : TypeProxy if ! isClassRef(tp1) =>
282
+ approximateUnion(next(tp1) | tp.tp2)
283
+ case _ =>
284
+ tp.tp2 match {
285
+ case tp2 : TypeProxy if ! isClassRef(tp2) =>
286
+ approximateUnion(tp.tp1 | next(tp2))
287
+ case _ =>
288
+ val commonBaseClasses = tp.mapReduceOr(_.baseClasses)(intersect)
289
+ val doms = dominators(commonBaseClasses, Nil )
290
+ doms.map(tp.baseTypeWithArgs).reduceLeft(AndType .apply)
291
+ }
292
+ }
275
293
case tp @ AndType (tp1, tp2) =>
276
294
tp derived_& (approximateUnion(tp1), approximateUnion(tp2))
277
295
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