From: Rico Tzschichholz Date: Thu, 21 Oct 2021 15:42:37 +0000 (+0200) Subject: vala: Correctly output signature of callable throwing error X-Git-Tag: 0.55.1~123 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a1fe512404de175528e533354e36b811903390d;p=thirdparty%2Fvala.git vala: Correctly output signature of callable throwing error --- 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 93f8738db..6ea2349d0 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 (); - get_error_types (error_types); + callable_symbol.get_error_types (error_types); if (error_types.size > 0) { builder.append (" throws ");