diff options
Diffstat (limited to 'tests/patmat/t2442')
-rw-r--r-- | tests/patmat/t2442/MyEnum.java | 3 | ||||
-rw-r--r-- | tests/patmat/t2442/MySecondEnum.java | 6 | ||||
-rw-r--r-- | tests/patmat/t2442/expected.check | 9 | ||||
-rw-r--r-- | tests/patmat/t2442/t2442.scala | 15 |
4 files changed, 33 insertions, 0 deletions
diff --git a/tests/patmat/t2442/MyEnum.java b/tests/patmat/t2442/MyEnum.java new file mode 100644 index 000000000..3ffbbb31b --- /dev/null +++ b/tests/patmat/t2442/MyEnum.java @@ -0,0 +1,3 @@ +public enum MyEnum { + ONE, TWO, THREE; +}
\ No newline at end of file diff --git a/tests/patmat/t2442/MySecondEnum.java b/tests/patmat/t2442/MySecondEnum.java new file mode 100644 index 000000000..0f841286d --- /dev/null +++ b/tests/patmat/t2442/MySecondEnum.java @@ -0,0 +1,6 @@ +public enum MySecondEnum { + RED(1), BLUE(2) { public void foo() {} }; + MySecondEnum(int i) {} + + public void foo() {} +}
\ No newline at end of file diff --git a/tests/patmat/t2442/expected.check b/tests/patmat/t2442/expected.check new file mode 100644 index 000000000..33110ce43 --- /dev/null +++ b/tests/patmat/t2442/expected.check @@ -0,0 +1,9 @@ +./tests/patmat/t2442/t2442.scala:4: warning: match may not be exhaustive. +It would fail on the following input: THREE + def f(e: MyEnum) = e match { + ^ +./tests/patmat/t2442/t2442.scala:11: warning: match may not be exhaustive. +It would fail on the following input: BLUE + def g(e: MySecondEnum) = e match { + ^ +two warnings found diff --git a/tests/patmat/t2442/t2442.scala b/tests/patmat/t2442/t2442.scala new file mode 100644 index 000000000..b0a0f3cd4 --- /dev/null +++ b/tests/patmat/t2442/t2442.scala @@ -0,0 +1,15 @@ +class Test { + import MyEnum._ + + def f(e: MyEnum) = e match { + case ONE => println("one") + case TWO => println("two") + // missing case --> exhaustivity warning! + } + + import MySecondEnum._ + def g(e: MySecondEnum) = e match { + case RED => println("red") + // missing case --> exhaustivity warning! + } +}
\ No newline at end of file |