From 95966d8fd0c37c86fbe6f77ed85f6372928bf4a5 Mon Sep 17 00:00:00 2001 From: Hamza Remmal Date: Thu, 11 Sep 2025 11:38:37 +0200 Subject: [PATCH] fix: do not transform `Ident` to `This` in PostTyper anymore [Cherry-picked d03af581af220a937a4bcee0e317ce346326403c] --- .../src/dotty/tools/dotc/transform/PostTyper.scala | 6 +----- tests/run/i23875.check | 3 +++ tests/run/i23875.scala | 11 +++++++++++ 3 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 tests/run/i23875.check create mode 100644 tests/run/i23875.scala 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))