From dc19b2fb49dbb486f4c37b866aa4d272515ac4d7 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` --- 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 5111a9517fab..9c1e4951a798 100644 --- a/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala @@ -232,6 +232,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