[vala/staging: 2/2] codegen: Method needs to throw error if their base method does
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging: 2/2] codegen: Method needs to throw error if their base method does
- Date: Sat, 27 Jan 2018 12:47:55 +0000 (UTC)
commit fec9fd6c30e5571565010028f705f6a0ddb945da
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Jan 27 13:23:53 2018 +0100
codegen: Method needs to throw error if their base method does
https://bugzilla.gnome.org/show_bug.cgi?id=614294
tests/Makefile.am | 1 +
tests/methods/bug614294.test | 13 +++++++++++++
vala/valamethod.vala | 13 +++++++++++--
3 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index aba0612..d1bd872 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -78,6 +78,7 @@ TESTS = \
methods/bug598738.vala \
methods/bug599892.vala \
methods/bug613483.vala \
+ methods/bug614294.test \
methods/bug615450.test \
methods/bug620673.vala \
methods/bug622570.vala \
diff --git a/tests/methods/bug614294.test b/tests/methods/bug614294.test
new file mode 100644
index 0000000..fe089d3
--- /dev/null
+++ b/tests/methods/bug614294.test
@@ -0,0 +1,13 @@
+Invalid Code
+
+interface IFoo : Object {
+ public abstract void foo () throws Error;
+}
+
+class Bar : Object, IFoo {
+ public virtual void foo () {
+ }
+}
+
+void main () {
+}
diff --git a/vala/valamethod.vala b/vala/valamethod.vala
index 66c131b..c5ea230 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -386,10 +386,19 @@ public class Vala.Method : Subroutine, Callable {
return false;
}
+ var error_types = get_error_types ();
+ var base_error_types = base_method.get_error_types ();
+
+ // method must throw error if the base method does
+ if (error_types.size == 0 && base_error_types.size > 0) {
+ invalid_match = "missing error type";
+ return false;
+ }
+
/* this method may throw less but not more errors than the base method */
- foreach (DataType method_error_type in get_error_types ()) {
+ foreach (DataType method_error_type in error_types) {
bool match = false;
- foreach (DataType base_method_error_type in base_method.get_error_types ()) {
+ foreach (DataType base_method_error_type in base_error_types) {
if (method_error_type.compatible (base_method_error_type)) {
match = true;
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]