diff --git a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala index 9f79c063dc03..d1246aacf7d5 100644 --- a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala +++ b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala @@ -391,11 +391,7 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase => checkNotPackage(tree) else registerNeedsInlining(tree) - val tree1 = checkUsableAsValue(tree) - tree1.tpe match { - case tpe: ThisType => This(tpe.cls).withSpan(tree.span) - case _ => tree1 - } + checkUsableAsValue(tree) case tree @ Select(qual, name) => registerNeedsInlining(tree) if name.isTypeName then diff --git a/tests/run/i23875.check b/tests/run/i23875.check new file mode 100644 index 000000000000..36bc6136b8bf --- /dev/null +++ b/tests/run/i23875.check @@ -0,0 +1,3 @@ +true +false +false diff --git a/tests/run/i23875.scala b/tests/run/i23875.scala new file mode 100644 index 000000000000..6993fb39f50b --- /dev/null +++ b/tests/run/i23875.scala @@ -0,0 +1,11 @@ +object Foo { + override def equals(that : Any) = that match { + case _: this.type => true + case _ => false + } +} + +@main def Test = + println(Foo.equals(Foo)) + println(Foo.equals(new AnyRef {})) + println(Foo.equals(0))