aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala15
-rw-r--r--tests/pos/t112606A.scala (renamed from tests/untried/pos/t112606A.scala)0
2 files changed, 14 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index 612b78f79..b0fc68ba8 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -536,7 +536,20 @@ class TypeComparer(initctx: Context) extends DotClass {
(tp1.symbol eq NullClass) && tp2.dealias.typeSymbol.isNullableClass
}
case tp1: SingletonType =>
- isNewSubType(tp1.underlying.widenExpr, tp2)
+ isNewSubType(tp1.underlying.widenExpr, tp2) || {
+ // if tp2 == p.type and p: q.type then try tp1 <:< q.type as a last effort.
+ tp2 match {
+ case tp2: TermRef =>
+ tp2.info match {
+ case tp2i: TermRef =>
+ isSubType(tp1, tp2i)
+ case _ =>
+ false
+ }
+ case _ =>
+ false
+ }
+ }
case tp1: RefinedType =>
isNewSubType(tp1.parent, tp2)
case AndType(tp11, tp12) =>
diff --git a/tests/untried/pos/t112606A.scala b/tests/pos/t112606A.scala
index 5bf532f8d..5bf532f8d 100644
--- a/tests/untried/pos/t112606A.scala
+++ b/tests/pos/t112606A.scala