Skip to content

Commit 31a6f89

Browse files
oderskyBlaisorblade
authored andcommitted
XXX Special case comparison with Any
Add the rule T <: Any for any *-Type T. This was not include fully before. We did have the rule that T <: Any, if Any is in the base types of T. However, it could be that the base type wrt Any does not exist. Example: Any#L <: Any yielded false before, now yields true. This error manifested itself in i4031.scala. With the new rule, we can drop again the special case in derivedSelect. TODO: in the context of scala#4108, this seems questionable. Also, `Any#L` seems an invalid type (even tho it is sound to consider it empty), and we'd probably not want to accept it if the user writes it; here it is only OK because it's introduced by avoidance. Or are user-written types checked elsewhere?
1 parent 75ba857 commit 31a6f89

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling {
406406
if (cls2 eq AnyKindClass) return true
407407
if (tp1.isRef(NothingClass)) return true
408408
if (tp1.isLambdaSub) return false
409+
if (cls2 eq AnyClass) return true
409410
// Note: We would like to replace this by `if (tp1.hasHigherKind)`
410411
// but right now we cannot since some parts of the standard library rely on the
411412
// idiom that e.g. `List <: Any`. We have to bootstrap without scalac first.

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4588,7 +4588,7 @@ object Types {
45884588
forwarded.orElse(
45894589
range(super.derivedSelect(tp, preLo).loBound, super.derivedSelect(tp, preHi).hiBound))
45904590
case _ =>
4591-
if (pre == defn.AnyType) pre else super.derivedSelect(tp, pre) match {
4591+
super.derivedSelect(tp, pre) match {
45924592
case TypeBounds(lo, hi) => range(lo, hi)
45934593
case tp => tp
45944594
}

0 commit comments

Comments
 (0)