From 1bcf664b64cd08a84939278fb312e72849505f22 Mon Sep 17 00:00:00 2001 From: Hamza Remmal Date: Sat, 3 May 2025 12:18:26 +0200 Subject: [PATCH] fix: synthesise value of `this.type` in `ValueOf` [Cherry-picked dc19b2fb49dbb486f4c37b866aa4d272515ac4d7] --- compiler/src/dotty/tools/dotc/typer/Synthesizer.scala | 2 ++ tests/pos/i23086.scala | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 tests/pos/i23086.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala b/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala index dca270f683c9..2c85294a3a94 100644 --- a/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala @@ -231,6 +231,8 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context): withNoErrors(success(Literal(Constant(())))) case n: TermRef => withNoErrors(success(ref(n))) + case ts: ThisType => + withNoErrors(success(This(ts.cls))) case tp => EmptyTreeNoError case _ => diff --git a/tests/pos/i23086.scala b/tests/pos/i23086.scala new file mode 100644 index 000000000000..2f8ee8689ad4 --- /dev/null +++ b/tests/pos/i23086.scala @@ -0,0 +1,2 @@ +class Test: + val _: this.type = summon[ValueOf[this.type]].value