]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Correctly output signature of callable throwing error
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 21 Oct 2021 15:42:37 +0000 (17:42 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 21 Oct 2021 15:48:32 +0000 (17:48 +0200)
tests/Makefile.am
tests/delegates/incompatible-error-argument-2.test [new file with mode: 0644]
tests/delegates/incompatible-error-argument.test [new file with mode: 0644]
vala/valacallabletype.vala

index 209836d651ab0afe068f0fca3623d098c89e1485..243fc7b5d2fc14149728265046b4b1873aadb829 100644 (file)
@@ -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 (file)
index 0000000..50b422a
--- /dev/null
@@ -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 (file)
index 0000000..f980022
--- /dev/null
@@ -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);
+}
index 93f8738db403742e4daaa2854da32e4b46a48844..6ea2349d0ed99f7d2b7ad05a34ff34adfdad8ee7 100644 (file)
@@ -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 ");