[vala/0.48] vala: Really check compatiblity of error types for delegate symbol
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.48] vala: Really check compatiblity of error types for delegate symbol
- Date: Sun, 24 Oct 2021 13:13:01 +0000 (UTC)
commit 28f00dc6d153a1f023b6bf1dc78bc25d2e22013e
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Oct 21 13:34:51 2021 +0200
vala: Really check compatiblity of error types for delegate symbol
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1242
tests/Makefile.am | 1 +
tests/delegates/incompatible-error-assignment.test | 18 ++++++++++++++++++
vala/valadelegatetype.vala | 4 ++--
3 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2957f7f8e..7ee57b6d2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -403,6 +403,7 @@ TESTS = \
delegates/implicit-local-variable.vala \
delegates/incompatible.test \
delegates/incompatible-assignment.test \
+ delegates/incompatible-error-assignment.test \
delegates/incompatible-initializer.test \
delegates/incompatible-target.test \
delegates/instance-method-to-no-target.test \
diff --git a/tests/delegates/incompatible-error-assignment.test
b/tests/delegates/incompatible-error-assignment.test
new file mode 100644
index 000000000..94b5c492a
--- /dev/null
+++ b/tests/delegates/incompatible-error-assignment.test
@@ -0,0 +1,18 @@
+Invalid Code
+
+errordomain FooError {
+ FAIL;
+}
+
+errordomain BarError {
+ FAIL;
+}
+
+delegate void FooFunc () throws FooError;
+
+delegate void BarFunc () throws BarError;
+
+void main () {
+ FooFunc f = () => { throw new FooError.FAIL (""); };
+ BarFunc b = f;
+}
diff --git a/vala/valadelegatetype.vala b/vala/valadelegatetype.vala
index 9d831954a..efe3181a8 100644
--- a/vala/valadelegatetype.vala
+++ b/vala/valadelegatetype.vala
@@ -162,11 +162,11 @@ public class Vala.DelegateType : CallableType {
// target-delegate may throw less but not more errors than the delegate
var error_types = new ArrayList<DataType> ();
- get_error_types (error_types);
+ delegate_symbol.get_error_types (error_types);
foreach (DataType error_type in error_types) {
bool match = false;
var delegate_error_types = new ArrayList<DataType> ();
- dt_target.get_error_types (delegate_error_types);
+ dt_target.delegate_symbol.get_error_types (delegate_error_types);
foreach (DataType delegate_error_type in delegate_error_types) {
if (error_type.compatible (delegate_error_type)) {
match = true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]