From 720bff8dc45bcbdd58fa55e2fcc54fbf2c10f589 Mon Sep 17 00:00:00 2001 From: Chris Kipp Date: Sun, 14 May 2023 11:55:55 +0200 Subject: [PATCH] test: add in a regression test for #11118 This adds in a regression test showing that just like in Scala 2 a user sees a warning about how the right hand side doesn't match the type of the left. closes #11118 --- tests/neg/i11118.check | 12 ++++++++++++ tests/neg/i11118.scala | 2 ++ 2 files changed, 14 insertions(+) create mode 100644 tests/neg/i11118.check create mode 100644 tests/neg/i11118.scala diff --git a/tests/neg/i11118.check b/tests/neg/i11118.check new file mode 100644 index 000000000000..0af98c7f580a --- /dev/null +++ b/tests/neg/i11118.check @@ -0,0 +1,12 @@ +-- Warning: tests/neg/i11118.scala:2:12 -------------------------------------------------------------------------------- +2 |val (a,b) = (1,2,3) // error // warning + | ^^^^^^^ + | pattern's type (Any, Any) does not match the right hand side expression's type (Int, Int, Int) + | + | If the narrowing is intentional, this can be communicated by adding `: @unchecked` after the expression, + | which may result in a MatchError at runtime. + | This patch can be rewritten automatically under -rewrite -source 3.2-migration. +-- Error: tests/neg/i11118.scala:2:4 ----------------------------------------------------------------------------------- +2 |val (a,b) = (1,2,3) // error // warning + | ^ + | this case is unreachable since type (Int, Int, Int) is not a subclass of class Tuple2 diff --git a/tests/neg/i11118.scala b/tests/neg/i11118.scala new file mode 100644 index 000000000000..23d9b2b604b6 --- /dev/null +++ b/tests/neg/i11118.scala @@ -0,0 +1,2 @@ +// https://github.com/lampepfl/dotty/issues/11118 +val (a,b) = (1,2,3) // error // warning