aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeComparer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-10-02 19:02:20 +0200
committerMartin Odersky <odersky@gmail.com>2015-10-06 13:51:39 +0200
commit0838b81bea4d579f812c02fafdc50e2b1920c059 (patch)
tree56ca7afdae15fda2ba5dc4b99dd74dd1562fecb5 /src/dotty/tools/dotc/core/TypeComparer.scala
parent6497d02675e651a79383c43f6ef38be918be1867 (diff)
downloaddotty-0838b81bea4d579f812c02fafdc50e2b1920c059.tar.gz
dotty-0838b81bea4d579f812c02fafdc50e2b1920c059.tar.bz2
dotty-0838b81bea4d579f812c02fafdc50e2b1920c059.zip
Add explanations for rewritings
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeComparer.scala')
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index 5555d13ba..5fbffe6e9 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -347,6 +347,9 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
case OrType(tp21, tp22) =>
// Rewrite T1 <: (T211 & T212) | T22 to T1 <: (T211 | T22) and T1 <: (T212 | T22)
// and analogously for T1 <: T21 | (T221 & T222)
+ // `|' types to the right of <: are problematic, because
+ // we have to choose one constraint set or another, which might cut off
+ // solutions. The rewriting delays the point where we have to choose.
tp21 match {
case AndType(tp211, tp212) =>
return isSubType(tp1, OrType(tp211, tp22)) && isSubType(tp1, OrType(tp212, tp22))
@@ -460,6 +463,9 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
case AndType(tp11, tp12) =>
// Rewrite (T111 | T112) & T12 <: T2 to (T111 & T12) <: T2 and (T112 | T12) <: T2
// and analogously for T11 & (T121 | T122) & T12 <: T2
+ // `&' types to the left of <: are problematic, because
+ // we have to choose one constraint set or another, which might cut off
+ // solutions. The rewriting delays the point where we have to choose.
tp11 match {
case OrType(tp111, tp112) =>
return isSubType(AndType(tp111, tp12), tp2) && isSubType(AndType(tp112, tp12), tp2)