[vala/staging] vala: Abstract and virtual methods may not be variadic



commit 5fb5abc08093427790bc8dbae3e1cc92ee92f0bd
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Mon May 14 14:13:04 2018 +0200

    vala: Abstract and virtual methods may not be variadic
    
    The chain-up of the variadic parameter is not possible.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=643088

 tests/Makefile.am            |    1 +
 tests/methods/bug643088.test |    8 ++++++++
 vala/valamethod.vala         |    6 ++++++
 3 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 764ca19..21e80f9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -90,6 +90,7 @@ TESTS = \
        methods/bug642350.vala \
        methods/bug642885.vala \
        methods/bug642899.vala \
+       methods/bug643088.test \
        methods/bug646345.vala \
        methods/bug648030.test \
        methods/bug648320.vala \
diff --git a/tests/methods/bug643088.test b/tests/methods/bug643088.test
new file mode 100644
index 0000000..7db9be9
--- /dev/null
+++ b/tests/methods/bug643088.test
@@ -0,0 +1,8 @@
+Invalid Code
+
+class Foo {
+       public abstract void bar (int p, ...);
+}
+
+void main () {
+}
diff --git a/vala/valamethod.vala b/vala/valamethod.vala
index 95bcfbe..e6d9fb5 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -647,6 +647,12 @@ 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 `...'.");
+                       return false;
+               }
+
                if (is_abstract) {
                        if (parent_symbol is Class) {
                                var cl = (Class) parent_symbol;


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