aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeComparer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-12-15 14:05:46 +0100
committerMartin Odersky <odersky@gmail.com>2015-12-15 17:51:23 +0100
commitee76fda79d446a2d6db51cb4af032a8e92936013 (patch)
tree38e6b3d67b66c66344a4d919a35d1693c71601ee /src/dotty/tools/dotc/core/TypeComparer.scala
parent300992407ca0e03eeda93cbb1a34ebc5907586b5 (diff)
downloaddotty-ee76fda79d446a2d6db51cb4af032a8e92936013.tar.gz
dotty-ee76fda79d446a2d6db51cb4af032a8e92936013.tar.bz2
dotty-ee76fda79d446a2d6db51cb4af032a8e92936013.zip
Dont push `|' inside refined types.
As the comment explains, this is not sound.
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeComparer.scala')
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index 163fa4919..b3d926a29 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -1106,18 +1106,15 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
NoType
}
- /** Try to distribute `|` inside type, detect and handle conflicts */
+ /** Try to distribute `|` inside type, detect and handle conflicts.
+ * Note that, unlike for `&`, a disjunction cannot be pushed into
+ * a refined or applied type. Example:
+ *
+ * List[T] | List[U] is not the same as List[T | U].
+ *
+ * The rhs is a proper supertype of the lhs.
+ */
private def distributeOr(tp1: Type, tp2: Type): Type = tp1 match {
- case tp1: RefinedType =>
- tp2 match {
- case tp2: RefinedType if tp1.refinedName == tp2.refinedName =>
- tp1.derivedRefinedType(
- tp1.parent | tp2.parent,
- tp1.refinedName,
- tp1.refinedInfo | tp2.refinedInfo.substRefinedThis(tp2, RefinedThis(tp1)))
- case _ =>
- NoType
- }
case tp1: TypeBounds =>
tp2 match {
case tp2: TypeBounds => tp1 | tp2