diff options
author | Martin Odersky <odersky@gmail.com> | 2013-06-18 23:23:24 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-06-18 23:23:24 +0200 |
commit | 928a2a99288c3aa425654e63aea5ddc70359d4ac (patch) | |
tree | b431d9a9e06e423dbd3761eb63970cda0d9ac580 /src/dotty/tools/dotc/core | |
parent | f8a42a0584d855a0548c20c7434ed83a59647ed9 (diff) | |
download | dotty-928a2a99288c3aa425654e63aea5ddc70359d4ac.tar.gz dotty-928a2a99288c3aa425654e63aea5ddc70359d4ac.tar.bz2 dotty-928a2a99288c3aa425654e63aea5ddc70359d4ac.zip |
Distribute & into TypeTypes.
&, | on two TypeTypes yielded AndTypes and OrTypes, which is wrong. We now turn any ClassInfoTypes into TypeBounds and distribute the operator into the bounds, creating a TypeBounds type.
Diffstat (limited to 'src/dotty/tools/dotc/core')
-rw-r--r-- | src/dotty/tools/dotc/core/TypeOps.scala | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala index 164335554..7d82cbffe 100644 --- a/src/dotty/tools/dotc/core/TypeOps.scala +++ b/src/dotty/tools/dotc/core/TypeOps.scala @@ -114,7 +114,20 @@ trait TypeOps { this: Context => else { val t2 = mergeIfSub(tp2, tp1) if (t2.exists) t2 - else AndType(tp1, tp2) + else { + tp1 match { + case tp1: TypeType => + tp2 match { + case tp2: TypeType => + val b1 = tp1.bounds + val b2 = tp2.bounds + return TypeBounds(b1.lo | b2.lo, b1.hi & b2.hi) + case _ => + } + case _ => + } + AndType(tp1, tp2) + } } } } @@ -132,7 +145,20 @@ trait TypeOps { this: Context => else { val t2 = mergeIfSuper(tp2, tp1) if (t2.exists) t2 - else OrType(tp1, tp2) + else { + tp1 match { + case tp1: TypeType => + tp2 match { + case tp2: TypeType => + val b1 = t1.bounds + val b2 = t2.bounds + return TypeBounds(b1.lo & b2.lo, b1.hi | b2.hi) + case _ => + } + case _ => + } + OrType(tp1, tp2) + } } } |