[vala/staging] 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/staging] vala: Really check compatiblity of error types for delegate symbol
- Date: Thu, 21 Oct 2021 11:43:51 +0000 (UTC)
commit 2f9638777518fb3190276fdbd6a015b0e2c33c12
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 | 16 ++++++++++++++++
vala/valadelegatetype.vala | 4 ++--
3 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 800bb6db8..209836d65 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -413,6 +413,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..e6fb54607
--- /dev/null
+++ b/tests/delegates/incompatible-error-assignment.test
@@ -0,0 +1,16 @@
+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 304da9eb2..8b51f324c 100644
--- a/vala/valadelegatetype.vala
+++ b/vala/valadelegatetype.vala
@@ -168,11 +168,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]