diff options
-rw-r--r-- | src/reflect/scala/reflect/internal/tpe/TypeComparers.scala | 4 | ||||
-rw-r--r-- | test/files/pos/t7520.scala | 10 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala b/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala index 68844a29b0..63f17dff34 100644 --- a/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala +++ b/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala @@ -358,8 +358,10 @@ trait TypeComparers { /** Does type `tp1` conform to `tp2`? */ private def isSubType2(tp1: Type, tp2: Type, depth: Int): Boolean = { + def retry(lhs: Type, rhs: Type) = ((lhs ne tp1) || (rhs ne tp2)) && isSubType(lhs, rhs, depth) + if (isSingleType(tp1) && isSingleType(tp2) || isConstantType(tp1) && isConstantType(tp2)) - return (tp1 =:= tp2) + return (tp1 =:= tp2) || retry(tp1.underlying, tp2) if (tp1.isHigherKinded || tp2.isHigherKinded) return isHKSubType(tp1, tp2, depth) diff --git a/test/files/pos/t7520.scala b/test/files/pos/t7520.scala new file mode 100644 index 0000000000..747f5278e5 --- /dev/null +++ b/test/files/pos/t7520.scala @@ -0,0 +1,10 @@ +class A { + val x: Singleton with this.type = this + val y: this.type = x +} + +class B { + val x = "" + val xs: x.type with Singleton = x + val y: x.type = xs +} |