aboutsummaryrefslogtreecommitdiff
path: root/src/dotty
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty')
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala8
-rw-r--r--src/dotty/tools/dotc/core/Types.scala4
2 files changed, 9 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index 8ce1ad354..79ec7ad3c 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -796,8 +796,12 @@ class TypeComparer(initctx: Context) extends DotClass with Skolemization {
def hasMatchingMember(name: Name, tp1: Type, tp2: RefinedType): Boolean = /*>|>*/ ctx.traceIndented(s"hasMatchingMember($tp1 . $name, ${tp2.refinedInfo}) ${tp1.member(name).info.show}", subtyping) /*<|<*/ {
val saved = skolemsOutstanding
try {
- val base = ensureSingleton(tp1)
- var rinfo2 = tp2.refinedInfo.substRefinedThis(0, base)
+ var base = tp1
+ var rinfo2 = tp2.refinedInfo
+ if (tp2.refinementRefersToThis) {
+ base = ensureSingleton(base)
+ rinfo2 = rinfo2.substRefinedThis(0, base)
+ }
def qualifies(m: SingleDenotation) = isSubType(m.info, rinfo2)
def memberMatches(mbr: Denotation): Boolean = mbr match { // inlined hasAltWith for performance
case mbr: SingleDenotation => qualifies(mbr)
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 920c9c6f8..21997c5fa 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -438,7 +438,9 @@ object Types {
val pdenot = go(tp.parent)
val rinfo = pre match {
case pre: RefinedType => tp.refinedInfo.substThis0(tp, RefinedThis(pre, -1))
- case _ => tp.refinedInfo.substRefinedThis(0, pre)
+ case _ =>
+ if (tp.refinementRefersToThis) tp.refinedInfo.substRefinedThis(0, pre)
+ else tp.refinedInfo
}
if (Types.goRefinedCheck) {
val rinfo0 = tp.refinedInfo.substThis0(tp, pre)