[vala/0.54] vala: Correctly output signature of callable throwing error



commit 0ab8113bd083999708628816c238eb606b00f8f7
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Thu Oct 21 17:42:37 2021 +0200

    vala: Correctly output signature of callable throwing error

 tests/Makefile.am                                  |  2 ++
 tests/delegates/incompatible-error-argument-2.test | 22 ++++++++++++++++++++++
 tests/delegates/incompatible-error-argument.test   | 21 +++++++++++++++++++++
 vala/valacallabletype.vala                         |  2 +-
 4 files changed, 46 insertions(+), 1 deletion(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 209836d65..243fc7b5d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -414,6 +414,8 @@ TESTS = \
        delegates/incompatible.test \
        delegates/incompatible-assignment.test \
        delegates/incompatible-error-assignment.test \
+       delegates/incompatible-error-argument.test \
+       delegates/incompatible-error-argument-2.test \
        delegates/incompatible-initializer.test \
        delegates/incompatible-target.test \
        delegates/instance-method-to-no-target.test \
diff --git a/tests/delegates/incompatible-error-argument-2.test 
b/tests/delegates/incompatible-error-argument-2.test
new file mode 100644
index 000000000..50b422a52
--- /dev/null
+++ b/tests/delegates/incompatible-error-argument-2.test
@@ -0,0 +1,22 @@
+Invalid Code
+
+errordomain FooError {
+       FAIL;
+}
+
+errordomain BarError {
+       FAIL;
+}
+
+delegate void FooFunc () throws FooError;
+
+void bar () throws BarError {
+       throw new BarError.FAIL ("");
+}
+
+void foo (FooFunc f) {
+}
+
+void main () {
+       foo (bar);
+}
diff --git a/tests/delegates/incompatible-error-argument.test 
b/tests/delegates/incompatible-error-argument.test
new file mode 100644
index 000000000..f98002288
--- /dev/null
+++ b/tests/delegates/incompatible-error-argument.test
@@ -0,0 +1,21 @@
+Invalid Code
+
+errordomain FooError {
+       FAIL;
+}
+
+errordomain BarError {
+       FAIL;
+}
+
+delegate void FooFunc () throws FooError;
+
+delegate void BarFunc () throws BarError;
+
+void foo (FooFunc f) {
+}
+
+void main () {
+       BarFunc bar = () => { throw new BarError.FAIL (""); };
+       foo (bar);
+}
diff --git a/vala/valacallabletype.vala b/vala/valacallabletype.vala
index a3da19518..f0e032204 100644
--- a/vala/valacallabletype.vala
+++ b/vala/valacallabletype.vala
@@ -127,7 +127,7 @@ public abstract class Vala.CallableType : DataType {
 
                // Append error-types
                var error_types = new ArrayList<DataType> ();
-               get_error_types (error_types);
+               callable_symbol.get_error_types (error_types);
                if (error_types.size > 0) {
                        builder.append (" throws ");
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]