[vala/staging] vala: params-array parameter is not allowed in abstract/virtual method
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] vala: params-array parameter is not allowed in abstract/virtual method
- Date: Tue, 5 May 2020 10:39:03 +0000 (UTC)
commit c75950de668f08fbf9ca15262534b9ed387b0ca3
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue May 5 12:28:32 2020 +0200
vala: params-array parameter is not allowed in abstract/virtual method
Fixes https://gitlab.gnome.org/GNOME/vala/issues/985
tests/Makefile.am | 1 +
tests/methods/params-array-abstract.test | 8 ++++++++
vala/valamethod.vala | 4 ++--
3 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index af8fe4d74..b30704f86 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
index 000000000..29a02d276
--- /dev/null
+++ b/tests/methods/params-array-abstract.test
@@ -0,0 +1,8 @@
+Invalid Code
+
+abstract class Foo {
+ public abstract void bar (params int[] a);
+}
+
+void main () {
+}
diff --git a/vala/valamethod.vala b/vala/valamethod.vala
index 35e0cc810..e617f9d61 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]