diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index 8e94e20219d1..0a88c0fa6fe7 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -61,8 +61,9 @@ class PlainPrinter(_ctx: Context) extends Printer { homogenize(tp.info) case tp: LazyRef => homogenize(tp.ref) - case AppliedType(tycon, args) => - tycon.dealias.appliedTo(args) + case tp @ AppliedType(tycon, args) => + if (defn.isCompiletimeAppliedType(tycon.typeSymbol)) tp.tryCompiletimeConstantFold + else tycon.dealias.appliedTo(args) case _ => tp } diff --git a/tests/pos/singleton-ops-test-issue-8287.scala b/tests/pos/singleton-ops-test-issue-8287.scala new file mode 100644 index 000000000000..ab92d43ec292 --- /dev/null +++ b/tests/pos/singleton-ops-test-issue-8287.scala @@ -0,0 +1,14 @@ +import scala.compiletime.ops.int._ +import scala.annotation.infix + +object Test { + class Vec[S <: Int] { + @infix def concat [RS <: Int](that : Vec[RS]) : Vec[S + RS] = new Vec[S + RS] + } + + val v1 = new Vec[1] + val v2 = new Vec[2] + val v3 : Vec[3] = v1 concat v2 + val v3a = v1 concat v2 + val v3b : Vec[3] = v3a +} \ No newline at end of file