diff options
author | Simon Ochsenreither <simon@ochsenreither.de> | 2016-01-07 19:07:45 +0100 |
---|---|---|
committer | Simon Ochsenreither <simon@ochsenreither.de> | 2016-01-14 00:01:40 +0100 |
commit | 11783c3c2a6692cfbb41b14734504b86101ed955 (patch) | |
tree | 094d7e5b3155f2325e8d6d290772433b1382228e /test/files | |
parent | fb22e2b0a73605d654c153e02d454e5cec21f355 (diff) | |
download | scala-11783c3c2a6692cfbb41b14734504b86101ed955.tar.gz scala-11783c3c2a6692cfbb41b14734504b86101ed955.tar.bz2 scala-11783c3c2a6692cfbb41b14734504b86101ed955.zip |
SI-8700 Exhaustiveness warning for enums from Java source
Until now, the warning was only emitted for enums from Java class files.
This commit fixes it by
- aligning the flags set in JavaParsers with the flags set in
ClassfileParser (which are required by the pattern matcher to
even consider checking exhaustiveness)
- adding the enum members as childs to the class holding the enum
as done in ClassfileParser so that the pattern matcher sees the enum
members when looking for the sealed children of a type
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/neg/t8700a.check | 11 | ||||
-rw-r--r-- | test/files/neg/t8700a.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t8700a/Bar.scala | 9 | ||||
-rw-r--r-- | test/files/neg/t8700a/Baz.java | 11 | ||||
-rw-r--r-- | test/files/neg/t8700a/Foo.java | 4 | ||||
-rw-r--r-- | test/files/neg/t8700b.check | 11 | ||||
-rw-r--r-- | test/files/neg/t8700b.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t8700b/Bar_2.scala | 9 | ||||
-rw-r--r-- | test/files/neg/t8700b/Baz_1.java | 11 | ||||
-rw-r--r-- | test/files/neg/t8700b/Foo_1.java | 4 |
10 files changed, 72 insertions, 0 deletions
diff --git a/test/files/neg/t8700a.check b/test/files/neg/t8700a.check new file mode 100644 index 0000000000..ce7945a3fc --- /dev/null +++ b/test/files/neg/t8700a.check @@ -0,0 +1,11 @@ +Bar.scala:2: warning: match may not be exhaustive. +It would fail on the following input: B + def bar1(foo: Foo) = foo match { + ^ +Bar.scala:6: warning: match may not be exhaustive. +It would fail on the following input: B + def bar2(foo: Baz) = foo match { + ^ +error: No warnings can be incurred under -Xfatal-warnings. +two warnings found +one error found diff --git a/test/files/neg/t8700a.flags b/test/files/neg/t8700a.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t8700a.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t8700a/Bar.scala b/test/files/neg/t8700a/Bar.scala new file mode 100644 index 0000000000..33ad8e9877 --- /dev/null +++ b/test/files/neg/t8700a/Bar.scala @@ -0,0 +1,9 @@ +object Bar { + def bar1(foo: Foo) = foo match { + case Foo.A => 1 + } + + def bar2(foo: Baz) = foo match { + case Baz.A => 1 + } +} diff --git a/test/files/neg/t8700a/Baz.java b/test/files/neg/t8700a/Baz.java new file mode 100644 index 0000000000..f85ad40802 --- /dev/null +++ b/test/files/neg/t8700a/Baz.java @@ -0,0 +1,11 @@ +public enum Baz { + A { + public void baz1() {} + }, + B { + public void baz1() {} + }; + + public abstract void baz1(); + public void baz2() {} +} diff --git a/test/files/neg/t8700a/Foo.java b/test/files/neg/t8700a/Foo.java new file mode 100644 index 0000000000..cc8e9daf1f --- /dev/null +++ b/test/files/neg/t8700a/Foo.java @@ -0,0 +1,4 @@ +public enum Foo { + A, + B +} diff --git a/test/files/neg/t8700b.check b/test/files/neg/t8700b.check new file mode 100644 index 0000000000..3bff78dd29 --- /dev/null +++ b/test/files/neg/t8700b.check @@ -0,0 +1,11 @@ +Bar_2.scala:2: warning: match may not be exhaustive. +It would fail on the following input: B + def bar1(foo: Foo_1) = foo match { + ^ +Bar_2.scala:6: warning: match may not be exhaustive. +It would fail on the following input: B + def bar2(foo: Baz_1) = foo match { + ^ +error: No warnings can be incurred under -Xfatal-warnings. +two warnings found +one error found diff --git a/test/files/neg/t8700b.flags b/test/files/neg/t8700b.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t8700b.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t8700b/Bar_2.scala b/test/files/neg/t8700b/Bar_2.scala new file mode 100644 index 0000000000..97ba16df27 --- /dev/null +++ b/test/files/neg/t8700b/Bar_2.scala @@ -0,0 +1,9 @@ +object Bar { + def bar1(foo: Foo_1) = foo match { + case Foo_1.A => 1 + } + + def bar2(foo: Baz_1) = foo match { + case Baz_1.A => 1 + } +} diff --git a/test/files/neg/t8700b/Baz_1.java b/test/files/neg/t8700b/Baz_1.java new file mode 100644 index 0000000000..6a057c2c9c --- /dev/null +++ b/test/files/neg/t8700b/Baz_1.java @@ -0,0 +1,11 @@ +public enum Baz_1 { + A { + public void baz1() {} + }, + B { + public void baz1() {} + }; + + public abstract void baz1(); + public void baz2() {} +} diff --git a/test/files/neg/t8700b/Foo_1.java b/test/files/neg/t8700b/Foo_1.java new file mode 100644 index 0000000000..22656bdedd --- /dev/null +++ b/test/files/neg/t8700b/Foo_1.java @@ -0,0 +1,4 @@ +public enum Foo_1 { + A, + B +} |