From c5192226dae2ac3466c51f762b2ddd3002439114 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 11 Dec 2023 18:44:59 +0100 Subject: [PATCH] Add regression test for #17429 Alphanumeric infix operator syntax will warn from `3.4`. Fixes #17429 --- tests/warn/i17429.check | 6 ++++++ tests/warn/i17429.scala | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 tests/warn/i17429.check create mode 100644 tests/warn/i17429.scala diff --git a/tests/warn/i17429.check b/tests/warn/i17429.check new file mode 100644 index 000000000000..3496f3d6f106 --- /dev/null +++ b/tests/warn/i17429.check @@ -0,0 +1,6 @@ +-- Warning: tests/warn/i17429.scala:3:17 ------------------------------------------------------------------------------- +3 | println(A(1) plus A(2)) // warn + | ^^^^ + | Alphanumeric method plus is not declared infix; it should not be used as infix operator. + | Instead, use method syntax .plus(...) or backticked identifier `plus`. + | The latter can be rewritten automatically under -rewrite -source 3.4-migration. diff --git a/tests/warn/i17429.scala b/tests/warn/i17429.scala new file mode 100644 index 000000000000..4c7616303de5 --- /dev/null +++ b/tests/warn/i17429.scala @@ -0,0 +1,3 @@ +case class A(a:Int): + def plus(a:A) = A(this.a+a.a) + println(A(1) plus A(2)) // warn