From 5cddbc7c99dd77a9f1a7937a1c0761271fa7fee9 Mon Sep 17 00:00:00 2001 From: Oron Port Date: Tue, 11 Feb 2020 15:29:46 +0200 Subject: [PATCH 1/3] add test for issue #8287 --- tests/pos/singleton-ops-test-issue-8287.scala | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/pos/singleton-ops-test-issue-8287.scala 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 From 588982165be5f6d9d4b5e16e085ebece23559708 Mon Sep 17 00:00:00 2001 From: Oron Port Date: Tue, 11 Feb 2020 16:09:14 +0200 Subject: [PATCH 2/3] Fixes #8287 --- compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index 8e94e20219d1..1e9726d10a3d 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 } From 5d1064e0685d24d17e2dc336b1b061317c67ec52 Mon Sep 17 00:00:00 2001 From: Oron Port Date: Tue, 11 Feb 2020 16:20:02 +0200 Subject: [PATCH 3/3] fixed style according to review --- compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index 1e9726d10a3d..0a88c0fa6fe7 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -61,7 +61,7 @@ class PlainPrinter(_ctx: Context) extends Printer { homogenize(tp.info) case tp: LazyRef => homogenize(tp.ref) - case tp@AppliedType(tycon, args) => + case tp @ AppliedType(tycon, args) => if (defn.isCompiletimeAppliedType(tycon.typeSymbol)) tp.tryCompiletimeConstantFold else tycon.dealias.appliedTo(args) case _ =>