diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index 735f6f11dad7..9f35f170d192 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -1596,7 +1596,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling * Note: It would be legal to do the lifting also if M does not contain opaque types, * but in this case the retries in tryLiftedToThis would be redundant. */ - def liftToThis(tp: Type): Type = { + private def liftToThis(tp: Type): Type = { def findEnclosingThis(moduleClass: Symbol, from: Symbol): Type = if ((from.owner eq moduleClass) && from.isPackageObject && from.is(Opaque)) from.thisType diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 53a10a64c277..072527ce7fce 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -758,18 +758,6 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer typedSelectWithAdapt(tree, pt, qual) else EmptyTree - // Otherwise, heal member selection on an opaque reference, - // reusing the logic in TypeComparer. - def tryLiftToThis() = - val wtp = qual.tpe.widen - val liftedTp = comparing(_.liftToThis(wtp)) - if liftedTp ne wtp then - val qual1 = qual.cast(liftedTp) - val tree1 = cpy.Select(tree0)(qual1, selName) - val rawType1 = selectionType(tree1, qual1) - tryType(tree1, qual1, rawType1) - else EmptyTree - // Otherwise, try to expand a named tuple selection def tryNamedTupleSelection() = val namedTupleElems = qual.tpe.widenDealias.namedTupleElementTypes @@ -881,7 +869,6 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer tryType(tree, qual, rawType) .orElse(trySimplifyApply()) .orElse(tryInstantiateTypeVar()) - .orElse(tryLiftToThis()) .orElse(tryNamedTupleSelection()) .orElse(trySmallGenericTuple(qual, withCast = true)) .orElse(tryExt(tree, qual)) diff --git a/tests/pos/i19609.orig.scala b/tests/pos/i19609.orig.scala deleted file mode 100644 index 62622075dbed..000000000000 --- a/tests/pos/i19609.orig.scala +++ /dev/null @@ -1,12 +0,0 @@ -object o { - opaque type T = String - - summon[o.T =:= T] // OK - summon[o.T =:= String] // OK - - def test1(t: T): Int = - t.length // OK - - def test2(t: o.T): Int = - t.length // Error: value length is not a member of Playground.o.T -} diff --git a/tests/pos/i19609.scala b/tests/pos/i19609.scala deleted file mode 100644 index 0879fa16c7cf..000000000000 --- a/tests/pos/i19609.scala +++ /dev/null @@ -1,24 +0,0 @@ -object o { u => - opaque type T = String - - def st = summon[String =:= T] - def su = summon[String =:= u.T] - def so = summon[String =:= o.T] - - def ts = summon[T =:= String] - def tu = summon[T =:= u.T] - def to = summon[T =:= o.T] - - def us = summon[u.T =:= String] - def ut = summon[u.T =:= T] - def uo = summon[u.T =:= o.T] - - def os = summon[o.T =:= String] - def ot = summon[o.T =:= T] - def ou = summon[o.T =:= u.T] - - def ms(x: String): Int = x.length // ok - def mt(x: T): Int = x.length // ok - def mu(x: u.T): Int = x.length // ok - def mo(x: o.T): Int = x.length // was: error: value length is not a member of o.T -}