diff options
author | Martin Odersky <odersky@gmail.com> | 2016-01-19 21:26:22 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-01-20 10:53:48 +0100 |
commit | eb1197c87b212bd3b776ce9e24f550e80888e5e4 (patch) | |
tree | f41eb3267a218ae562e16317485d99f486c86517 /src/dotty/tools/dotc/core/TypeOps.scala | |
parent | 1aa8fbb56e95d7aea04b338d3edf7d53077b804a (diff) | |
download | dotty-eb1197c87b212bd3b776ce9e24f550e80888e5e4.tar.gz dotty-eb1197c87b212bd3b776ce9e24f550e80888e5e4.tar.bz2 dotty-eb1197c87b212bd3b776ce9e24f550e80888e5e4.zip |
Fix #998
Needed a fix in approximateUnion.
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeOps.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/TypeOps.scala | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala index 6896468ba..70e8302d9 100644 --- a/src/dotty/tools/dotc/core/TypeOps.scala +++ b/src/dotty/tools/dotc/core/TypeOps.scala @@ -269,9 +269,28 @@ trait TypeOps { this: Context => // TODO: Make standalone object. if (ctx.featureEnabled(defn.LanguageModuleClass, nme.keepUnions)) tp else tp match { case tp: OrType => - val commonBaseClasses = tp.mapReduceOr(_.baseClasses)(intersect) - val doms = dominators(commonBaseClasses, Nil) - doms.map(tp.baseTypeWithArgs).reduceLeft(AndType.apply) + def isClassRef(tp: Type): Boolean = tp match { + case tp: TypeRef => tp.symbol.isClass + case tp: RefinedType => isClassRef(tp.parent) + case _ => false + } + def next(tp: TypeProxy) = tp.underlying match { + case TypeBounds(_, hi) => hi + case nx => nx + } + tp.tp1 match { + case tp1: TypeProxy if !isClassRef(tp1) => + approximateUnion(next(tp1) | tp.tp2) + case _ => + tp.tp2 match { + case tp2: TypeProxy if !isClassRef(tp2) => + approximateUnion(tp.tp1 | next(tp2)) + case _ => + val commonBaseClasses = tp.mapReduceOr(_.baseClasses)(intersect) + val doms = dominators(commonBaseClasses, Nil) + doms.map(tp.baseTypeWithArgs).reduceLeft(AndType.apply) + } + } case tp @ AndType(tp1, tp2) => tp derived_& (approximateUnion(tp1), approximateUnion(tp2)) case tp: RefinedType => |