]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: params-array parameter is not allowed in abstract/virtual method c75950de668f08fbf9ca15262534b9ed387b0ca3
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 5 May 2020 10:28:32 +0000 (12:28 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 5 May 2020 10:29:48 +0000 (12:29 +0200)
Fixes https://gitlab.gnome.org/GNOME/vala/issues/985

tests/Makefile.am
tests/methods/params-array-abstract.test [new file with mode: 0644]
vala/valamethod.vala

index af8fe4d745ae1cc96969b10bd9f82d8a380b53ce..b30704f86886f8b6165423b56ac47e09993839ad 100644 (file)
@@ -176,6 +176,7 @@ TESTS = \
        methods/delegate-target.vala \
        methods/generics.vala \
        methods/params-array.vala \
+       methods/params-array-abstract.test \
        methods/print-attribute.vala \
        methods/print-attribute-invalid.test \
        methods/printf-invalid.test \
diff --git a/tests/methods/params-array-abstract.test b/tests/methods/params-array-abstract.test
new file mode 100644 (file)
index 0000000..29a02d2
--- /dev/null
@@ -0,0 +1,8 @@
+Invalid Code
+
+abstract class Foo {
+    public abstract void bar (params int[] a);
+}
+
+void main () {
+}
index 35e0cc810875e12b8c73e478e2706f58a77ecbfb..e617f9d615c7a56bfe57d528762537791a1b70a9 100644 (file)
@@ -248,7 +248,7 @@ public class Vala.Method : Subroutine, Callable {
 
        public bool is_variadic () {
                foreach (Parameter param in parameters) {
-                       if (param.ellipsis) {
+                       if (param.ellipsis || param.params_array) {
                                return true;
                        }
                }
@@ -728,7 +728,7 @@ public class Vala.Method : Subroutine, Callable {
 
                if (is_variadic () && (is_abstract || is_virtual)) {
                        error = true;
-                       Report.error (source_reference, "Abstract and virtual methods may not be variadic. Use a `va_list' parameter instead of `...'.");
+                       Report.error (source_reference, "Abstract and virtual methods may not be variadic. Use a `va_list' parameter instead of `...' or params-array.");
                        return false;
                }